mdfreeman
New Member
Hey!
I am looking for a more efficient way to have my VBA roll through a list of items in a SlicerCache.
Current wisdom of the internet below results in repeated resetting of the filtered SlicerItems looping over and over again to get to each item. It is very inefficient when your list of items is long.
I know I can count the number of items in the SlicerCaches with the code below.
It would be great is there was way to select and item based on the position in the list of items in the SlicerCaches. With that you could roll through each value from what is in position 1 to the total value of the items in the list.
Anyone know if something like the index option exists?
Mark
I am looking for a more efficient way to have my VBA roll through a list of items in a SlicerCache.
Current wisdom of the internet below results in repeated resetting of the filtered SlicerItems looping over and over again to get to each item. It is very inefficient when your list of items is long.
Code:
Dim sI As SlicerItem, sI2 As SlicerItem, sC As SlicerCache
Set sC = ActiveWorkbook.SlicerCaches("Slicer_site")
With sC
For Each sI In sC.SlicerItems
sC.ClearManualFilter
For Each sI2 In sC.SlicerItems
If sI.Name = sI2.Name Then sI2.Selected = True Else: sI2.Selected = False
Next
''Insert your code to do what you want with the filtered pivot table
''Copy to a new tab or whatever you want
Next
End With
I know I can count the number of items in the SlicerCaches with the code below.
Code:
ActiveWorkbook.SlicerCaches(1).VisibleSlicerItems.Count
It would be great is there was way to select and item based on the position in the list of items in the SlicerCaches. With that you could roll through each value from what is in position 1 to the total value of the items in the list.
Anyone know if something like the index option exists?
Mark