Bparivar
Bparivar

Reputation: 11

Looping through filtered items in slicer

I am attempting to write a macro but am caught up. How do you create a loop that will loop through only visible objects in an already filtered slicer.

Image below is the slicer I want to use ("slicer_Route") and I only the loop to loop through the first 4 darkened objects. (These were the result of another filter)

SLICER:

enter image description here

Upvotes: 1

Views: 2127

Answers (2)

fenixen
fenixen

Reputation: 51

You can solve it by using the property HasData in sliceritems.

Upvotes: 0

M--
M--

Reputation: 28955

I don't know what you want to do but this goes through Visible Items:

Dim sC As SlicerCache
Dim sI As SlicerItem

Set sC = ActiveWorkbook.SlicerCaches("Slicer_Route")

For Each sI in sC.SlicerItems
If sI.Selected = True Then

Debug.Print sI.Name 'This is an example, you can do what you want with that item

End If

Next sI

If you provide more detailed question, you may get further help.

Upvotes: 1

Related Questions