Grizlore
Active Member
- Joined
- Aug 22, 2006
- Messages
- 259
Could someone have a look at this code and see if you can spot what the problem is please?
I intend this to on-shutdown hide all sheets apart from the one named "LOCKED"
and on-startup, hide "LOCKED" and show all the other.
It works if there is a sheet names "Sheet1", if not it doesn't
Any pointers would be appreciated
I intend this to on-shutdown hide all sheets apart from the one named "LOCKED"
and on-startup, hide "LOCKED" and show all the other.
It works if there is a sheet names "Sheet1", if not it doesn't
Code:
Option Explicit
Sub Auto_close()
Dim wsSheet As Worksheet
Application.ScreenUpdating = False
For Each wsSheet In ThisWorkbook.Worksheets
If wsSheet.Name = "LOCKED" Then
wsSheet.Visible = xlSheetVisible
Else
wsSheet.Visible = xlSheetVeryHidden
End If
Next wsSheet
ActiveWorkbook.Save
Application.ScreenUpdating = True
End Sub
'//////////////////////////////
Sub Auto_open()
If ActiveWorkbook.ReadOnly = True Then GoTo CloseDown
Dim wsSheet As Worksheet
For Each wsSheet In ThisWorkbook.Worksheets
If wsSheet.Name <> "LOCKED" Then
wsSheet.Visible = xlSheetVisible
End If
Next wsSheet
Sheets("LOCKED").Visible = xlSheetVeryHidden
End Sub
Any pointers would be appreciated