SlicerPivotTables.AddPivotTable method (Excel)

Adds a reference to a PivotTable to the SlicerPivotTables collection.

Syntax

expression.AddPivotTable (PivotTable)

expression A variable that represents a SlicerPivotTables object.

Parameters

Name Required/Optional Data type Description
PivotTable Required PivotTable A PivotTable object that represents the PivotTable to add.

Return value

Nothing

Remarks

When a PivotTable is added to the SlicerPivotTables collection, it can be filtered by its parent SlicerCache and the slicers associated with it.

Example

The following code example adds PivotTable1 to the slicer cache associated with the Customer slicer.

Dim pvts As SlicerPivotTables 
Set pvts = ActiveWorkbook.SlicerCaches("Slicer_Customer").PivotTables 
pvts.AddPivotTable(ActiveSheet.PivotTables("PivotTable1"))

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.