Hello,
I'm using a vba macro to store the selected items in an OLAP slicer and then update a second OLAP slicer. I found a great macro for storing the selected items as a string array, but can't figure out how to then use the string array in the formula for updating the second slicer.
This is the formula I've used to populate my string array (please ignore declaration of slicer variables; they are working):
This populates the ar variable with the following text:
ar(0) = [Calendar].[GL Month].&[GL-2016-01]
ar(1) = [Calendar].[GL Month].&[GL-2016-02]
ar(3) = [Calendar].[GL Month].&[GL-2016-03]
This variable is dynamic in length, dependent on how many slicer filters are selected.
To update the second slicer, the following code is required:
How can I populate the array formula to update the second slicer so that it includes each value in the string array ar?
Thanks for your help!
I'm using a vba macro to store the selected items in an OLAP slicer and then update a second OLAP slicer. I found a great macro for storing the selected items as a string array, but can't figure out how to then use the string array in the formula for updating the second slicer.
This is the formula I've used to populate my string array (please ignore declaration of slicer variables; they are working):
Code:
Dim ar() As String
ReDim ar(UBound(scCY.VisibleSlicerItemsList) - 1)
For i = 0 To UBound(scCY.VisibleSlicerItemsList) - 1
svalue = scCY.VisibleSlicerItemsList(i + 1)
ar(i) = svalue
Next
This populates the ar variable with the following text:
ar(0) = [Calendar].[GL Month].&[GL-2016-01]
ar(1) = [Calendar].[GL Month].&[GL-2016-02]
ar(3) = [Calendar].[GL Month].&[GL-2016-03]
This variable is dynamic in length, dependent on how many slicer filters are selected.
To update the second slicer, the following code is required:
Code:
ActiveWorkbook.SlicerCaches("Slicer_GL_Month5").VisibleSlicerItemsList = Array ("[Calendar].[GL Month].&[GL-2015-01]", _
"[Calendar].[GL Month].&[GL-2015-02]", "[Calendar].[GL Month].&[GL-2015-03]"
How can I populate the array formula to update the second slicer so that it includes each value in the string array ar?
Code:
[COLOR=#574123]ActiveWorkbook.SlicerCaches("Slicer_GL_Month5").VisibleSlicerItemsList = [/COLOR]Array (ar(0),ar(1),(ar(2),ar(n))
Thanks for your help!
Last edited: