1
votes

I have some code that clears the pivot table slicer cache in my workbook. I have two pivot tables in the workbook and i'd like to modify the code to clear the slicers only on a specific worksheet. Does anyone know how I can modify to do this?

Dim cache As SlicerCache
For Each cache In ActiveWorkbook.SlicerCaches
    If cache.FilterCleared = False Then cache.ClearManualFilter
Next cache

Thank you!

1

1 Answers

0
votes

This should point you in the right direction

Sub test()

Dim pt As PivotTable
Dim cache As Slicer

For Each pt In ActiveSheet.PivotTables
    For Each cache In pt.Slicers
        cache.SlicerCache.ClearAllFilters
    Next cache
Next pt

End Sub