SlicerCache Object (Excel)

Office 2013 and later

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA documentation.

Represents the current filter state for a slicer and information about which PivotCache or WorkbookConnection the slicer is connected to.

Use the SlicerCaches property of the Workbook object to access the collection of SlicerCache objects in a workbook.

Each slicer has a base SlicerCache object which represents the items displayed in the slicer and the current user interface state of the tiles displayed with their corresponding item captions. Each slicer control that the user sees in Excel is represented by a Slicer object that has a SlicerCache object associated with it.

The following code example creates a SlicerCache object based on the Customer Geography OLAP hierarchy from the connection to the AdventureWorks database, and then creates a slicer on the Country level of that hierarchy in Sheet2 of the workbook.

With ActiveWorkbook 
 .SlicerCaches.Add("AdventureWorks", _ 
 "[Customer].[Customer Geography]").Slicers.Add SlicerDestination:="Sheet2", _ 
 Level:="[Customer].[Customer Geography].[Country]", Caption:="Country" 
End With