Aim to achieve :
I want to change the source data for my pivot table in Excel using VB.Net to a named range.
I have :
table.ChangePivotCache(wb.PivotCaches.Create(SourceType:=Excel.XlPivotTableSourceType.xlDatabase, SourceData:=sheet.Names("name_of_NamedRange").RefersToRange))
Exception :
The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
SourceData needs to be a string that contains the address, including the sheet name, like ‘My Sheet’!A1:B10. Try this: