Hi
i have the below code, (its a bit larger than this, but this should be enough to show my problem)
i have a workbook with around 30 sheets , about 20 sheets contain personal info and are hidden, for the managers that need to see tho sheets i have given them personal macros as below, one to hide and lock and another to unhide
my problem is, historic sheets need to be opened and as they have agents that no longer exist the macros crash, i have used 'on error' as below, but that only seems to work once
can anybody show me what i am doing wrong or suggest a better alternative method
thanks
Wayne
i have the below code, (its a bit larger than this, but this should be enough to show my problem)
i have a workbook with around 30 sheets , about 20 sheets contain personal info and are hidden, for the managers that need to see tho sheets i have given them personal macros as below, one to hide and lock and another to unhide
my problem is, historic sheets need to be opened and as they have agents that no longer exist the macros crash, i have used 'on error' as below, but that only seems to work once
can anybody show me what i am doing wrong or suggest a better alternative method
thanks
Wayne
VBA Code:
Sub closesheets()
On Error GoTo Jan19
ActiveWorkbook.Unprotect Password:="ShouldIWorrydAboutCovid20?"
Sheets("Tom H").Visible = False
Sheets("Mark S").Visible = False
Sheets("Jane P").Visible = False
Sheets("Scott R").Visible = False
Sheets("Sarah K").Visible = False
Sheets("Steve F").Visible = False
Sheets("Geoff T").Visible = False
Sheets("Matt D").Visible = False
ActiveWorkbook.Protect Password:="ShouldIWorrydAboutCovid20?"
Exit Sub
Jan19:
On Error GoTo May18
ActiveWorkbook.Unprotect Password:="ShouldIWorrydAboutCovid20?"
Sheets("Caroline B").Visible = False
Sheets("Tom H").Visible = False
Sheets("Mark S").Visible = False
Sheets("Jane P").Visible = False
Sheets("Andrew F").Visible = False
Sheets("Sarah K").Visible = False
Sheets("Peter B").Visible = False
ActiveWorkbook.Protect Password:="ShouldIWorrydAboutCovid20?"
Exit Sub
May18:
On Error GoTo Feb17
ActiveWorkbook.Unprotect Password:="ShouldIWorrydAboutCovid20?"
Sheets("Caroline B").Visible = False
Sheets("Mike G").Visible = False
Sheets("Mark S").Visible = False
Sheets("Jane P").Visible = False
Sheets("Andrew F").Visible = False
Sheets("Peter B").Visible = False
ActiveWorkbook.Protect Password:="ShouldIWorrydAboutCovid20?"
Exit Sub