Class SlicerPivotTables (Excel VBA)
The class SlicerPivotTables represents information about the collection of PivotTables associated with the specified SlicerCache object. To use a SlicerPivotTables class variable it first needs to be instantiated, for example
Dim spts as SlicerPivotTables
Set spts = ActiveWorkbook.SlicerCaches(1).PivotTables
AddPivotTable
Adds a reference to a PivotTable to the SlicerPivotTables collection.
When a PivotTable is added to the SlicerPivotTables collection, it can be filtered by its parent SlicerCache and the slicers associated with it.
AddPivotTable (PivotTable)
PivotTable: A PivotTable object that represents the PivotTable to add.
Dim pvts As SlicerPivotTables
Set pvts = ActiveWorkbook.SlicerCaches("Slicer_Customer").PivotTables
pvts.AddPivotTable(ActiveSheet.PivotTables("PivotTable1"))
Count
Returns the number of objects in the collection.
Dim lngCount As Long
lngCount = ActiveWorkbook.SlicerCaches(1).PivotTables.Count
Item
Returns a single PivotTable object from the collection.
Item (Index)
Index: The name or index number of the object.
Dim pvtItem As PivotTable
Set pvtItem = ActiveWorkbook.SlicerCaches(1).PivotTables(Index:=1)
RemovePivotTable
Removes a reference to a PivotTable from the SlicerPivotTables collection.
When a PivotTable is removed from the SlicerPivotTables collection, it is no longer filtered by its parent SlicerCache object and the slicers associated with it.
RemovePivotTable (PivotTable)
PivotTable: A PivotTable object that represents the PivotTable to remove, or the name or index of the PivotTable in the collection.
Dim pvts As SlicerPivotTables
Set pvts = ActiveWorkbook.SlicerCaches("Slicer_Customer").PivotTables
pvts.RemovePivotTable("PivotTable1")