-1
I have a bunch of Month Tabs
What is one way to open a specific one with VBA? I tried using this snippet:
Private Sub Workbook_Open()
Dim ws As Worksheet
Dim mnth As String, dte As String, mday As String
mday = Now() - Weekday(Now(), 3)
mnth = Month(mday)
dte = Day(mday)
tabstr = mnth & "-" & dte
For Each ws In Worksheets
If ws.Name = tabstr Then
ws.Select
Exit For
End If
Next
End sub
but that's for sheet names that are named after dates formatted as mm-dd
, e.g. "11-7" or "11-14".
How do I change this code so it works for sheet names that contain month names like "May", "June", or "July"?