Hi VBA masters, I am a first time poster to chandoo, and a VBA newbie.
I am trying to use a macro to send the user to a hidden Sheet1, hide the current sheet called HOME, and select a slicer item ("LA"), and deselect the other items. Slicer has three items: CA, LA, MI.
Initially all three items are selected, until the user hits the macro.
Slicer name is SLICER_DC.
The slicer is connected to a PivotTable that comes from a data model.
I have a macro that sends the user to Sheet1 and it works no problem.
I just couldn't get the slicer to select LA, and deselect CA and MI.
I tried the approach below as a module but I couldn't get it to work.
The error code I get is: "Invalid procedure call or argument."
Could someone please help point me in the right direction?
Thank you!
I am trying to use a macro to send the user to a hidden Sheet1, hide the current sheet called HOME, and select a slicer item ("LA"), and deselect the other items. Slicer has three items: CA, LA, MI.
Initially all three items are selected, until the user hits the macro.
Slicer name is SLICER_DC.
The slicer is connected to a PivotTable that comes from a data model.
I have a macro that sends the user to Sheet1 and it works no problem.
I just couldn't get the slicer to select LA, and deselect CA and MI.
I tried the approach below as a module but I couldn't get it to work.
The error code I get is: "Invalid procedure call or argument."
Could someone please help point me in the right direction?
Thank you!
Code:
Sub Slicer()
Sheets("HOME").Select
Sheets("Sheet1").Visible = True
Sheets("Sheet1").Select
ActiveWorkbook.SlicerCaches("SLICER_DC1").ClearManualFilter
With ActiveWorkbook.SlicerCaches("SLICER_DC1")
.SlicerItems("LA").Selected = True
.SlicerItems("MI").Selected = False
.SlicerItems("CA").Selected = False
End With
End Sub
Last edited: