-->

Read all selected slicer item values to an array v

2019-08-26 09:35发布

问题:

How to read all selected slicer item values to an array variable? I thought this might work:

Dim MyArr() as Variant
MyArr = ActiveWorkbook.SlicerCaches(1).VisibleSlicerItemsList

But it does not. Some reference:
https://docs.microsoft.com/en-us/office/vba/api/excel.slicercache.visiblesliceritemslist

回答1:

You can't use VisibleSlicerItemsList, unless you are using an OLAP data source. From the documentation:

The VisibleSlicerItemsList property is only applicable for slicers that are based on OLAP data sources.

I think the easiest way is to iterate over VisibleSlicerItems.