VBA to loop sliceritems in one slicerCache

Sulen

New Member
Joined
Oct 27, 2020
Messages
1
Office Version
  1. 2013
Platform
  1. Windows
Hello,

Not sure if anyone has idea why my code gets stuck in below yellow line, The purpose of the code is to loop slicerItems one by one in one slicer.
I took quite a time but still can't figure out this.
Thanks in advance!


1603805901463.png

Dim sI As SlicerItem
Dim sI2 As SlicerItem
Dim sC As SlicerCache
Dim index As Integer
Set sC = ActiveWorkbook.SlicerCaches("Slicer_Region_Code")

With sC
For index = 1 To sC.SlicerCacheLevels.Count
For Each sI In sC.SlicerCacheLevels(index).SlicerItems

sC.ClearManualFilter

For Each sI2 In sC.SlicerCacheLevels(index).SlicerItems
If sI.Name = sI2.Name Then
sI2.Selected = True
Else: sI2.Selected = False
End If
Next
Next
Next

End With

End Sub
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

Forum statistics

Threads
1,215,009
Messages
6,122,674
Members
449,091
Latest member
peppernaut

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top