1) Получить текущую дату в формате, который мы можем использовать для проверки логики типа «Больше чем» ГГГГММ:
Dim currentDate As String
currentDate=Format(Now(), "YYYYMM")
2) Просмотрите ваши рабочие листы:
Dim currentDate As String
currentDate=Format(Now(), "YYYYMM")
Dim ws as Worksheet
For Each ws in ThisWorkbook.Worksheets
Next ws
3) Внутри этого цикла конвертируйте тест, если это рабочий лист с именем месяца. Используя InStr
здесь:
Dim currentDate As String
currentDate = Format(Now(), "YYYYMM")
Dim ws As Worksheet
Dim thisTabDate As String
For Each ws In ThisWorkbook.Worksheets
'Test to see if this is in the right format
If InStr(1, "Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec", Left(ws.Name, 3)) Then
End If
Next ws
4) Если это так, отформатируйте имя вкладки так, чтобы оно совпадало с ГГГГММ, и установите ее видимость
Dim currentDate As String
currentDate = Format(Now(), "YYYYMM")
Dim ws As Worksheet
Dim thisTabDate As String
For Each ws In ThisWorkbook.Worksheets
'Test to see if this is in the right format
If InStr(1, "Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec", Left(ws.Name, 3)) Then
'This is messy, but we are just cutting the tab name up, turning it into an actual date, and then formatting that.
thisTabDate = Format(CDate(Left(ws.Name, 3) & "-01-" & Right(ws.Name, 2)), "YYYYMM")
'Set the visible True/False to the result of the test
ws.Visible = (thisTabDate >= currentDate)
End If
Next ws