ActiveWorkbook.SlicerCaches("Slicer_xxxxx").ClearManualFilter
我需要取消选择所有切片器项目。
我试过了
For i = 1 To numberOfItems
On Error Resume Next
.SlicerItems(i).Selected = False
Next i
请帮忙
最佳答案
Public Sub unselectAllBut(slicerName As String, newSelection As String)
ThisWorkbook.SlicerCaches(slicerName).SlicerItems(newSelection).Selected = True
Dim slc As SlicerItem
For Each slc In ThisWorkbook.SlicerCaches(slicerName).SlicerItems
If Not slc.Caption = newSelection Then
slc.Selected = False
End If
Next slc
End Sub
试试这个! :)
例如:
unselectAllBut(UrSlicerName,您要选择的项目标题)
关于excel-vba - 需要VBA代码才能取消选择所有切片器项目,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22372880/