简体   繁体   中英

Need VBA Code for Deselect all slicer items

ActiveWorkbook.SlicerCaches("Slicer_xxxxx").ClearManualFilter

I need to deselect all slicer items. I tried this

For i = 1 To numberOfItems
On Error Resume Next
.SlicerItems(i).Selected = False
Next i

Please help

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

Try this! :)

Ex: unselectAllBut(UrSlicerName, Item's caption u want to select)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM