I am trying to create a macro that will change the data source for three pivot tables. Then, a single slicer that is already on the sheet will be connected to all three pivot tables. The pivot tables all will take their data from the same place.
When I try this, I get an error at the step to connect the slicer to pivot tables 2 and 3. If I run the macro with only the steps to change the data source for each pivot table, I noticed that the slicer only has one option in the "report connections" box instead of 3.
Here is what I have:
Sheets("Sales").Select
ActiveSheet.PivotTables("PivotTable1").ChangePivotCache ActiveWorkbook. _
PivotCaches.Create(SourceType:=xlDatabase, SourceData:="Table3", Version _
:=xlPivotTableVersion15)
ActiveSheet.PivotTables("PivotTable2").ChangePivotCache ActiveWorkbook. _
PivotCaches.Create(SourceType:=xlDatabase, SourceData:="Table3", Version _
:=xlPivotTableVersion15)
ActiveSheet.PivotTables("PivotTable3").ChangePivotCache ActiveWorkbook. _
PivotCaches.Create(SourceType:=xlDatabase, SourceData:="Table3", Version _
:=xlPivotTableVersion15)
ActiveWorkbook.SlicerCaches("Slicer_Year").PivotTables.AddPivotTable ( _
ActiveSheet.PivotTables("PivotTable1"))
ActiveWorkbook.SlicerCaches("Slicer_Year").PivotTables.AddPivotTable ( _
ActiveSheet.PivotTables("PivotTable2"))
ActiveWorkbook.SlicerCaches("Slicer_Year").PivotTables.AddPivotTable ( _
ActiveSheet.PivotTables("PivotTable3"))
Slicers
andSlicerCache
here jkp-ads.com/Articles/slicers03.asp. How to do it manually myexcelonline.com/blog/… – Shai Rado