我有一些代码可以清除工作簿中的数据透视表切片器缓存。我在工作簿中有两个数据透视表,我想修改代码以仅在特定工作表上清除切片器。有谁知道我可以修改这样做吗?
Dim cache As SlicerCache
For Each cache In ActiveWorkbook.SlicerCaches
If cache.FilterCleared = False Then cache.ClearManualFilter
Next cache
谢谢!
答案 0 :(得分:0)
这应该指向正确的方向
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