mahmed1
Well-known Member
- Joined
- Mar 28, 2009
- Messages
- 2,302
- Office Version
- 365
- 2016
- Platform
- Windows
Hi All,
Im trying to highlight all values in the slicer that has the word leaver in there but im getting this error 1004 application or object error
The slicer name to use in formulas is called Slicer_Area1
Here is the code used with power pivot (pivot tables)
Im trying to highlight all values in the slicer that has the word leaver in there but im getting this error 1004 application or object error
The slicer name to use in formulas is called Slicer_Area1
Here is the code used with power pivot (pivot tables)
Code:
Sub SelectLeavers()
Dim slcr As SlicerCache
Dim slc As Slicer
Dim si As SlicerItem
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
For Each si In ActiveWorkbook.SlicerCaches("Slicer_Area1").SlicerItems
If InStr(si.Name, "Leaver") > 0 Then
si.Selected = True
Else
si.Selected = False
End If
Next si
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Application.DisplayAlerts = False
ActiveWorkbook.RefreshAll
Application.DisplayAlerts = False
End Sub