Good day
I have an Excel file with about 50 "regular" pivot tables feeding from a single "regular" pivot cache.
Now I just created a Power Pivot data model using the same table as my exisiting "regular" pivot tables and would like my 50 pivot tables to feed from the new PowerPivot data model.
The pivot cache underlying the PowerPivot data model has CacheIndex = 6.
The following code works to change to the pivot cache between two "regular" pivot caches but fails when the new pivot cache is a PowerPivot cache.
(Error: Run-time error '1004' Application-defined or object-defined error)
Question: is there a way not to have to manually recreate all 50 pivot tables so that they feed from the PowerPivot data model? Thanks!
I have an Excel file with about 50 "regular" pivot tables feeding from a single "regular" pivot cache.
Now I just created a Power Pivot data model using the same table as my exisiting "regular" pivot tables and would like my 50 pivot tables to feed from the new PowerPivot data model.
The pivot cache underlying the PowerPivot data model has CacheIndex = 6.
The following code works to change to the pivot cache between two "regular" pivot caches but fails when the new pivot cache is a PowerPivot cache.
(Error: Run-time error '1004' Application-defined or object-defined error)
Question: is there a way not to have to manually recreate all 50 pivot tables so that they feed from the PowerPivot data model? Thanks!
VBA Code:
Sub MassChangePivotCacheWorksheetLevel()
Dim pt As PivotTable
Dim wks As Worksheet
aWbkName = ActiveWorkbook.Name
aShtName = ActiveSheet.Name
For Each pt In ActiveSheet.PivotTables
pt.CacheIndex = 6
Next pt
End Sub