Hi,
I have a workbook that has sheets called week 1 through to 52 and a sheet called dump.
I need to automatically hide from a workbook_open, every sheet BUT the "Dump" and "Week " & X where X is current week number and then the next 3 weeks.
For some reason, the code I've created doesn't work using OR logic but does when it's without.
Also, how can I use W as an array or variable to store the current week number and next 3 weeks instead of using 4 different variables?
Thanks,
I have a workbook that has sheets called week 1 through to 52 and a sheet called dump.
I need to automatically hide from a workbook_open, every sheet BUT the "Dump" and "Week " & X where X is current week number and then the next 3 weeks.
For some reason, the code I've created doesn't work using OR logic but does when it's without.
Also, how can I use W as an array or variable to store the current week number and next 3 weeks instead of using 4 different variables?
Thanks,
Code:
Sub HideNon4Weeks()
W = "Week " & Format(Date - 238, "ww")
NW = "Week " & Format(Date - 238, "ww") + 1
N2W = "Week " & Format(Date - 238, "ww") + 2
N3W = "Week " & Format(Date - 238, "ww") + 3
Application.ScreenUpdating = False
For Each sh In ThisWorkbook.Sheets
' sh.Visible = True
If sh.Name <> "Dump" Or sh.Name <> W Then sh.Visible = False
Next sh
Application.ScreenUpdating = True
End Sub