Dokat
Dokat

Reputation: 21

VBA code to clear all slicer filters and select

I have a very simple VBA code where I want to first clear all filters in the slicer then select RB.

Below is the code I am using without success:

ActiveWorkbook.SlicerCaches("Slicer_Manufacturer1").ClearManualFilter    
With ActiveWorkbook.SlicerCaches("Slicer_Manufacturer1")
.SlicerItems("RB").Selected = True
End With
End Sub

Can anyone help?

Upvotes: 0

Views: 5664

Answers (1)

mojo3340
mojo3340

Reputation: 549

Try this and let me know what happens:

Dim cache As SlicerCache 

For Each cache In ActiveWorkbook.SlicerCaches 
 cache.ClearManualFilter 
Next cache

With ActiveWorkbook.SlicerCaches("Slicer_Manufacturer1")
.SlicerItems("RB").Selected = True
End With
End Sub

Upvotes: 1

Related Questions