问题
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.
来源:https://stackoverflow.com/questions/54945719/read-all-selected-slicer-item-values-to-an-array-variable