The file works great except when I try to use the Protect Workbook function. I then get the Run time error when I try and close/open the file. I believe that my problem has something to do with failing to reset the screen views?
The reason I use the "Protect Workbook" function is because someone can right click the tabs at the bottom and then delete a worksheet - the "Protect Worksheet" function does not protect for this scenario.
Is there a way around this? I was thinking something along the lines of using the Macro Disable button and assigning a number to the softbutton selection, if Disabled then view only one, if enabled then view the others. Would I still need to reset the views in these cases?
Listed below is my code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.ScreenUpdating = False
Sheets("Warning").Visible = xlSheetVisible
' hide all sheet but Warning sheet
For Each sh In Worksheets
If Not sh.Name = "Warning" Then sh.Visible = xlVeryHidden
Next sh
End Sub
Private Sub Workbook_Open()
For Each sh In Worksheets
sh.Visible = xlSheetVisible
Next sh
' hide the warning sheet
Sheets("Warning").Visible = xlVeryHidden
End Sub
Thanks!