rob_sheeds
Board Regular
- Joined
- Dec 9, 2010
- Messages
- 57
Hi, I have read all there is in here on the Workbook_BeforeClose and I cant get it to work. The jist is to protect all sheets and the workbook whenever a user closes the workbook.
Current code is (which is under ThisWorkbook). Any help would be excellent and thanks in advance.
Current code is (which is under ThisWorkbook). Any help would be excellent and thanks in advance.
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call ProtectAllSheets
End Sub
Sub ProtectAllSheets()
'Protects ALL worksheets
For Each Shts In ThisWorkbook.Worksheets
Shts.Protect Password:="evo!@#"
Next
ActiveWorkbook.Protect Password:="evo!@#"
End Sub