TheMadTree
New Member
- Joined
- Mar 23, 2015
- Messages
- 25
Good afternoon,
I am trying to loop through all the sliceritems in a slicercache but I keep encountering errors.
Can anyone spot the error in the macro below?
Thank you!
I am trying to loop through all the sliceritems in a slicercache but I keep encountering errors.
Can anyone spot the error in the macro below?
Thank you!
Code:
Option Explicit
Sub Slicers()
Dim SCache As SlicerCache
Dim SItem As SlicerItem
Dim SItem2 As SlicerItem
Application.ScreenUpdating = False
Set SCache = ThisWorkbook.slicercaches("Slicer_Distributor_Name")
With SCache
For Each SItem In SCache.SlicerItems
Application.EnableEvents = False
SCache.ClearManualFilter
Application.EnableEvents = True
For Each SItem2 In SCache.SlicerItems
If SItem.Name = SItem2.Name Then SItem2.Selected = True Else: SItem2.Selected = False
Next
Next SItem
End With
Application.ScreenUpdating = True
End Sub