none
Clear Slicer Selection RRS feed

Answers

  • Do you mean clear all items in a slicer or unselect one item of a slicer?

    To clear all items in a slicer, you could use

    SlicerCache.ClearManualFilter Method (Excel)

    E.g.

    ActiveWorkbook.SlicerCaches("Slicer_LETTERS").ClearManualFilter

    To unselect one item of a slicer, you could use

    Sub sli()
    Dim a As String
    a = Range("A10").Value 'the value of which item you want to clear in slicer
    With ActiveWorkbook.SlicerCaches("Slicer_LETTERS")
    For i = 1 To .SlicerItems.Count
    'Select all items
     .SlicerItems(i).Selected = True
     If .SlicerItems(i).Value = a Then
     .SlicerItems(i).Selected = False
    End If
    Next
    End With
    '' if you know its index, you could use
    'With ActiveWorkbook.SlicerCaches("Slicer_LETTERS")
    'For i = 1 To .SlicerItems.Count
    ' .SlicerItems(i).Selected = True
    ' If i = 5 Then
    ' .SlicerItems(i).Selected = False
    'End If
    'Next
    'End With
    End Sub
    

    • Marked as answer by NadhMandava Thursday, September 15, 2016 2:40 PM
    Thursday, September 15, 2016 4:42 AM
    Moderator

All replies

  • Do you mean clear all items in a slicer or unselect one item of a slicer?

    To clear all items in a slicer, you could use

    SlicerCache.ClearManualFilter Method (Excel)

    E.g.

    ActiveWorkbook.SlicerCaches("Slicer_LETTERS").ClearManualFilter

    To unselect one item of a slicer, you could use

    Sub sli()
    Dim a As String
    a = Range("A10").Value 'the value of which item you want to clear in slicer
    With ActiveWorkbook.SlicerCaches("Slicer_LETTERS")
    For i = 1 To .SlicerItems.Count
    'Select all items
     .SlicerItems(i).Selected = True
     If .SlicerItems(i).Value = a Then
     .SlicerItems(i).Selected = False
    End If
    Next
    End With
    '' if you know its index, you could use
    'With ActiveWorkbook.SlicerCaches("Slicer_LETTERS")
    'For i = 1 To .SlicerItems.Count
    ' .SlicerItems(i).Selected = True
    ' If i = 5 Then
    ' .SlicerItems(i).Selected = False
    'End If
    'Next
    'End With
    End Sub
    

    • Marked as answer by NadhMandava Thursday, September 15, 2016 2:40 PM
    Thursday, September 15, 2016 4:42 AM
    Moderator
  • Thank you For Replay.

    I want to Clear All Items In a Slicer

    • Marked as answer by NadhMandava Thursday, September 15, 2016 2:40 PM
    • Unmarked as answer by NadhMandava Thursday, September 15, 2016 2:40 PM
    Thursday, September 15, 2016 2:30 PM