ActiveWorkbook.SlicerCaches("Slicer_xxxxx").ClearManualFilter
我需要取消选择所有切片器项目。 我试过这个
For i = 1 To numberOfItems
On Error Resume Next
.SlicerItems(i).Selected = False
Next i
请帮忙
答案 0 :(得分:5)
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,项目标题,你要选择)