mginsburg88
New Member
- Joined
- Mar 4, 2016
- Messages
- 9
Hi everyone - I am trying to lock all worksheets in my workbook when I close, but I want to allow people to group/ungroup columns. Do you know what I am doing wrong with my VBA code?
Sub ProtectAll()
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim wsheet As Worksheet
For Each wsheet In ActiveWorkbook.Worksheets
wsheet.Protect Password:="password", Contents:=True, userInterfaceOnly:=True
wsheet.EnableOutlining = True
Next wsheet
End Sub
Thanks in advance!
Sub ProtectAll()
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim wsheet As Worksheet
For Each wsheet In ActiveWorkbook.Worksheets
wsheet.Protect Password:="password", Contents:=True, userInterfaceOnly:=True
wsheet.EnableOutlining = True
Next wsheet
End Sub
Thanks in advance!