Baba_Yaga
New Member
- Joined
- Sep 1, 2017
- Messages
- 22
Hello Group, Im trying to find a VBA code that would allow me to Not only set the password for all the sheets, but also
set the options for the sheets.
I have a work book that Needs:
LOCKED,UNLOCKED,FORMAT COLUMNS, USE AUTO FILTER.
And for some reason when I use the code:
Sub protect_all_sheets()
top:
pass = InputBox("password?")
repass = InputBox("Verify Password")
If Not (pass = repass) Then
MsgBox "you made a boo boo"
Goto top
End If
For i = 1 To Worksheets.Count
If Worksheets(i).ProtectContents = True Then Goto oops
Next
For Each s In ActiveWorkbook.Worksheets
s.Protect Password:=pass
Next
Exit Sub
oops: MsgBox "I think you have some sheets that are already protected. Please unprotect all sheets then running this Macro."
End Sub
All of the sheets with revert back to just locked cells.
Any Help, or advice.
or did I try to divice by zero
set the options for the sheets.
I have a work book that Needs:
LOCKED,UNLOCKED,FORMAT COLUMNS, USE AUTO FILTER.
And for some reason when I use the code:
Sub protect_all_sheets()
top:
pass = InputBox("password?")
repass = InputBox("Verify Password")
If Not (pass = repass) Then
MsgBox "you made a boo boo"
Goto top
End If
For i = 1 To Worksheets.Count
If Worksheets(i).ProtectContents = True Then Goto oops
Next
For Each s In ActiveWorkbook.Worksheets
s.Protect Password:=pass
Next
Exit Sub
oops: MsgBox "I think you have some sheets that are already protected. Please unprotect all sheets then running this Macro."
End Sub
All of the sheets with revert back to just locked cells.
Any Help, or advice.
or did I try to divice by zero