Johnny C
Well-known Member
- Joined
- Nov 7, 2006
- Messages
- 1,069
- Office Version
- 365
- Platform
- Windows
I have a large workbook with many pivot tables linked to 2 external sources. VBA loops through sheets and pivot tables, then uses this code to change it
where pt is the pivot table and
strROINewSrc = 'F:\finance\Report 22\MUEIRE\03 Mar 22\Sales\[EIRESales (Mar - 22).xlsx]!Sales Datasheet'!$A:$AX"
strROINewSrc was created using GetOpenFilename so the file s there and it does have a tab called Sales Datasheet
But I get an error that it can't open the pivot table source.
yet I can go and manually change it on the worksheet so the new source file doesn't need to be open.
what am I doing wrong?
VBA Code:
pt.ChangePivotCache wkb.PivotCaches.Create(SourceType:=xlDatabase, SourceData:=strROINewSrc)
strROINewSrc = 'F:\finance\Report 22\MUEIRE\03 Mar 22\Sales\[EIRESales (Mar - 22).xlsx]!Sales Datasheet'!$A:$AX"
strROINewSrc was created using GetOpenFilename so the file s there and it does have a tab called Sales Datasheet
But I get an error that it can't open the pivot table source.
yet I can go and manually change it on the worksheet so the new source file doesn't need to be open.
what am I doing wrong?