Good evening OzGrid community,
I am new to this community and would like to thank you in advance for any assistance.
Before I post my question, and, as a courtesy to the Mr.Excel.com community, I did post a similar post in their forum but unfortunately it went unanswered. The question I am posing here is a bit similar but it addresses another issue.
So, here it goes - I have a slicer in which I have the following code:
Sub NextBtn() Dim sItem As SlicerItem Dim DtCache As SlicerCache Set DtCache = ActiveWorkbook.SlicerCaches("Slicer_DATE") For Each sItem In DtCache.SlicerItems If sItem.Selected = True Then Range("RegisterDate").Value = sItem.Name Exit For End If Next sItem DtCache.ClearManualFilter Set DtCache = Nothing Worksheets(3).Activate Range("RegisterLoc").Select End Sub
Essentially, the code loops through the "Slicer_DATE" slicer items, grabs the selected item, and, inserts the slicer item information into the "RegisterDate" named range cell. Now, the code, as is works great. However, what I would like the code to do (already tried to no avail) is to return a message box alerting the user if they have not selected an item and exit the subroutine.
If I used the line:
Though I do not receive an error message, the code will fire the message box but, it will still insert the first value of the slicer into the named range.
Please let me know if further clarification is needed. I am super, super grateful for any assistance.