• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

vba code do not wort wit an olap base pivot

Maxwolf

New Member
i have this code wohois working perfectly with a standard pivot tabel, it count the number of visible item in a slicer
Range("g2") = ActiveWorkbook.SlicerCaches("Segment_CNP1").VisibleSlicerItems.Count

but since i use now a OLAP base pivottable the code do not work anymore.


is there another way to count the number of item selevt in a slicer base on an OLAP table (Powerpivotable) ?

Thank you for your help
 
Sure there is. Remember that .VisibleSlicerItemsList is array of visible items.

So... to get highest subscript of array dimension you'd use UBound() function.
http://www.excelfunctions.net/vba-ubound-function.html

And since .VisibleSlicerItemsList is 1d array... no need for optional dimension argument.
Code:
Range("g2") = UBound(ActiveWorkbook.SlicerCaches("Segment_CNP1").VisibleSlicerItemsList)

FYI - Also, it is base 1 array (meaning that it will start at 1 as lowest subscript, not zero like most index/array).
 
Last edited:
Back
Top