SlicerCaches.Add Method (Excel)
Adds a new SlicerCache object to the collection.
Version Information
추가된 버전: Excel 2010
Syntax
식 .Add(Source, SourceField, Name)
식 A variable that represents a SlicerCaches collection.
Parameters
Name |
Required/Optional |
Data Type |
Description |
---|---|---|---|
Source |
필수 |
Variant |
The data source that the new SlicerCache will be based on. The argument passed to the Source parameter can be a WorkbookConnection object, a PivotTable object, or a string. If a PivotTable object is passed, the associated PivotCache object is used as the data source. If a string is passed, it is interpreted as the name of a WorkbookConnection object, and if no such WorkbookConnection object exists, a run-time error is generated. |
SourceField |
필수 |
Variant |
The name of the field in the data source to filter by. For non-OLAP data sources, use the PivotField object from the PivotCache object that the slicer is based on, or the unique name of that object (the value of the PivotField.Name property). For OLAP data sources, use the MDX unique name of the hierarchy that the SlicerCache is based on. You can also specify a level of the OLAP hierarchy, and Excel will use the corresponding hierarchy. |
Name |
선택 |
Variant |
The name Excel uses to reference the slicer cache (the value of the SlicerCache.Name property). If omitted, Excel will generate a name. By default, Excel concatenates "Slicer_" with the value of the PivotField.Caption property for slicers with non-OLAP data sources, or with the value of the CubeField.Caption property for slicers with OLAP data sources. (Replacing any spaces with "_".) If required to make the name unique in the workbook namespace, Excel adds an integer to the end of the generated name. If you specify a name that already exists in the workbook namespace, the Add method will fail. |
Return Value
SlicerCache
Example
The following code example adds a slicer cache based on the Customer Geography OLAP hierarchy.
ActiveWorkbook.SlicerCaches.Add(ActiveCell.PivotTable, _
"[Customer].[Customer Geography]")