I have a workbook with sheets for the months of the financial year ("JUL 2021" through to "JUN 2022"). Im hoping to hide sheets corresponding to future months.
I've tried:
Dim ws As Worksheet
Dim strMonth As String
strMonth = Format(Date, "MMM YYYY")
For Each ws in ActiveWorkbook.Worksheets
If ws.Name <= strMonth Then
ws.Visible = True
Else
ws.Visible = False
End If
Next ws
However, that is hiding all worksheets after current months by alphabetical order, not month.
I know it will be something really simple, I've only been using VBA for about a week so any help is appreciated