Hi, I am using the below VBA to select a slicer item based on a cell ref. This works fine, however if the item in the cell is not in the slicer then i want it to select an item in the slicer called "No Data"
The code i'm currently using is below, could someone please help me with auto selecting the item "No Data" if the cell ref is not an option in the slicer?
Many Thanks
Sub Temp1()
' Uber Eats Slicer
Dim UEselected As String
UEselected = ActiveSheet.Range("B5").Value
With ActiveWorkbook.SlicerCaches("Slicer_Brand1")
.ClearManualFilter
For Each oSlicerItem In .SlicerItems
If oSlicerItem.Name = UEselected Then
oSlicerItem.Selected = True
Else
oSlicerItem.Selected = False
End If
Next oSlicerItem
End With
End Sub
The code i'm currently using is below, could someone please help me with auto selecting the item "No Data" if the cell ref is not an option in the slicer?
Many Thanks
Sub Temp1()
' Uber Eats Slicer
Dim UEselected As String
UEselected = ActiveSheet.Range("B5").Value
With ActiveWorkbook.SlicerCaches("Slicer_Brand1")
.ClearManualFilter
For Each oSlicerItem In .SlicerItems
If oSlicerItem.Name = UEselected Then
oSlicerItem.Selected = True
Else
oSlicerItem.Selected = False
End If
Next oSlicerItem
End With
End Sub