Building on this question, I have a workbook with a pivot table from an OLAP cube. I need to be able to change a slicer for this pivot using the values in a selected range of cells. I can make the solution provided in the linked question work for one value, but I get a type mismatch error when trying to use an array.
This is the code I'm using. The [Branch Name] is the field I'm trying to set.
Dim sel_Array As Variant
Dim rng As Range
'Set rng = Selection
sel_Array = Selection.Value
ActiveWorkbook.SlicerCaches("Slicer_Branch_Name").VisibleSlicerItemsList = Array("[Dim Location].[Branch Name].&[" & sel_Array & "]")
I also tried using the rng variable to put "rng.Value" into the VisibleSlicerItemsList, but that didn't work either.