Slicers.Add method (Excel)

Creates a new slicer and returns a Slicer object.


expression.Add (SlicerDestination, Level, Name, Caption, Top, Left, Width, Height)

expression A variable that represents a Slicers object.


Name Required/Optional Data type Description
SlicerDestination Required Variant A String that specifies the name of the sheet, or a Worksheet object that represents the sheet, where the resulting slicer will be placed. The destination sheet must be in the workbook that contains the Slicers object specified by expression.
Level Optional Variant For OLAP data sources, the ordinal or the Multidimensional Expression (MDX) name of the level on which the slicer creation is based. Not supported for non-OLAP data sources.
Name Optional Variant The name of the slicer. Excel automatically generates a name if one is not specified. The name must be unique across all slicers within a workbook.
Caption Optional Variant The caption of the slicer.
Top Optional Variant The initial vertical position of the slicer, in points, relative to the upper-left corner of cell A1 on a worksheet.
Left Optional Variant The initial horizontal position of the slicer, in points, relative to the upper-left corner of cell A1 on a worksheet.
Width Optional Variant The initial width, in points, of the slicer control.
Height Optional Variant The initial height, in points, of the slicer control.

Return value



This example adds a SlicerCache object by using the OLAP data source AdventureWorks, and then adds a Slicer object to filter on the Country field.

Sub CreateNewSlicer() 
 ActiveWorkbook.SlicerCaches.Add("Adventure Works", _ 
 "[Customer].[Customer Geography]").Slicers.Add ActiveSheet, _ 
 "[Customer].[Customer Geography].[Country]", "Country 1", "Country", _ 
 252, 522, 144, 216) 
End Sub

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.