JoshLyman
New Member
- Joined
- Jan 11, 2023
- Messages
- 35
- Office Version
- 365
- 2010
- Platform
- Windows
Having some issues figuring out the right code (not super experienced). I would like, upon close, for all sheets to be protected (password 123), the workbook to be protected (password 123), and the tab called DASHBOARD to be hidden. Currently I have:
Any help would be greatly appreciated!
VBA Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Worksheets("DASHBOARD").Visible = False
Dim xSheet As Worksheet
Dim xPsw As String
xPsw = "123"
For Each xSheet In Worksheets
xSheet.Protect xPsw
Next
ActiveWorkbook.Protect Password:="123", Structure:=True, Windows:=True
End Sub
Any help would be greatly appreciated!