I generate a daily workbook with 40 tabs filled with tables. Once complete, I have VBA that goes through the tabs and selects certain slicer items or filters the data a certain way for presentation in daily meetings to hit the highlights. A few tabs won't have their full list of standard slicer items until mid-week, if at all, so the VBA I have will crash when the missing slicer items aren't available. Below the VBA has the full list of 15 slicer items, some weeks my actual data may be missing 1 or 2 lesser used items. How can I fix the VBA, so it picks the slicer item I need regardless of whether all the items are available?
Sample file is attached. Thank you.
Sheets("Track Workhours").Select
With ActiveWorkbook.SlicerCaches("Adhoc_Activity")
.SlicerItems("Assist Analyst 1").Selected = True
.SlicerItems("Assist Analyst 2").Selected = False
.SlicerItems("Assist Mgmt Intern").Selected = False
.SlicerItems("Assist Senior Analyst").Selected = False
.SlicerItems("Assist Team Project").Selected = False
.SlicerItems("Collection Mail Run").Selected = False
.SlicerItems("Driver Training").Selected = False
.SlicerItems("In-Office Training").Selected = False
.SlicerItems("Interoffice Hub").Selected = False
.SlicerItems("Loan to another facility").Selected = False
.SlicerItems("Misc. - Explanation Required!").Selected = False
.SlicerItems("New Hire Training").Selected = False
.SlicerItems("Out-of-Office Training").Selected = False
.SlicerItems("Priority Mail - Express Run").Selected = False
.SlicerItems("Sunday Work Hours").Selected = False
End With
Kyle Francis
Hi Kyle,
First tell us which Excel version you're using
Second, a copy of your file as sample removing private/sensitive data?
Will the item you want to select always be present? If not, what do you want to happen?
Excel Version Microsoft 365 MSO (Version 2405 Build 16.0.17628.20006) 64-bit
Yes, the desired slicer item is always present.
Thank you.