Hey, I'm hoping someone has a simple solution that I'm just missing. I'm looking to select slicers within a workbook based on the month and the year - there are other slicers I want to ignore. I'm naming each of the slicers based on the worksheet and am trying to loop through each sheet and select the month and year for each if a slicer exists on that page.
I've tried a few different ways to replace "ActiveSheet" but none of them have worked. I'm probably missing something simple. Any suggestions?
Rich (BB code):
sub SelectSlicers()
dim today as date
dim MonthString as string
today = now
MonthString = format(today,"mmm")
For Each item In ThisWorkbook.SlicerCaches(ActiveSheet & "_Month_Name").SlicerItems
If item.Name = MonthString Then
item.Selected = True
Else
item.Selected = False
End If
Next item
End sub
I've tried a few different ways to replace "ActiveSheet" but none of them have worked. I'm probably missing something simple. Any suggestions?