The below code is giving an odd result. The slicer has 22 options (#1 at top going down to #22 on bottom).
If I currently have #12 selected, and then run the code, it will select slicer options 1-12. If X = the # of currently selected slicer option, the code will select 1 - X, and the options below stay un-selected. The above is just an example and not meant to show a natural, or desired, starting point.
Other info that may be relevant: Multiselect = True, The 2nd to bottom option = "", The Last option -"blank"
What I want the code to do is select the 3rd to last option, which is the first (from bottom) option that isnt blank or null data. This explains the commented out line.
However, I cannot figure out why the code below is not deselecting all options.
Sub Slicer()
Dim WB As Workbook
Set WB = ThisWorkbook
Dim i As Integer
Dim n As Integer
With WB.SlicerCaches("Slicer_Processed_date")
n = .SlicerItems.Count
For i = 1 To n
If .SlicerItems(i).Selected = True Then
.SlicerItems(i).Selected = False
End If
Next i
'.SlicerItems(n - 2).Selected = True
End With
End Sub