N
Natalie
Hello All,
I have two macros: 1 to Protect All Sheets and 1 to Hide
sheets based on the month name. (Codes are below)
At the moment the Hide macro runs when the file opens but
the Protection one is run by click a macro button.
Basically I would like to combine the two so that when a
user opens a file it is protected and the hide macro runs.
Any help will be greatfully appreciated!
Natalie
Sub ProtectAllSheets()
Application.ScreenUpdating = False
Dim n As Single
For n = 1 To Sheets.Count
Sheets(n).Protect Password:="justme"
Next n
Application.ScreenUpdating = True
End Sub
Sub Workbook_Open()
Dim MyMonth As Integer
MyMonth = Month(Now())
Select Case MyMonth
Case 1 'If month number is 1 (Jan)
Sheets("Feb").Visible = False
Sheets("Mar").Visible = False
Case 2 'If Month number is 2 (Feb)
Sheets("Jan").Visible = False
Sheets("March").Visible = False
Case 3 'If Month number is 3 (Mar)
Sheets("Jan").Visible = False
Sheets("Mar").Visible = True
Sheets("Feb").Visible = False
End Select
End Sub
I have two macros: 1 to Protect All Sheets and 1 to Hide
sheets based on the month name. (Codes are below)
At the moment the Hide macro runs when the file opens but
the Protection one is run by click a macro button.
Basically I would like to combine the two so that when a
user opens a file it is protected and the hide macro runs.
Any help will be greatfully appreciated!
Natalie
Sub ProtectAllSheets()
Application.ScreenUpdating = False
Dim n As Single
For n = 1 To Sheets.Count
Sheets(n).Protect Password:="justme"
Next n
Application.ScreenUpdating = True
End Sub
Sub Workbook_Open()
Dim MyMonth As Integer
MyMonth = Month(Now())
Select Case MyMonth
Case 1 'If month number is 1 (Jan)
Sheets("Feb").Visible = False
Sheets("Mar").Visible = False
Case 2 'If Month number is 2 (Feb)
Sheets("Jan").Visible = False
Sheets("March").Visible = False
Case 3 'If Month number is 3 (Mar)
Sheets("Jan").Visible = False
Sheets("Mar").Visible = True
Sheets("Feb").Visible = False
End Select
End Sub