I am using the following VBA code to password lock multiple sheets in my excel spread sheet.
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
This works great but I also want to allow the users to insert comments. This is easily done by checking the edit objects box if I am password protecting one sheet at a time but I don't know if I can add it to this code to do this to all worksheets that I am password protecting. I am very new to VBA and found this code on line which has been a big help.
Thx in advance.
Josh
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
This works great but I also want to allow the users to insert comments. This is easily done by checking the edit objects box if I am password protecting one sheet at a time but I don't know if I can add it to this code to do this to all worksheets that I am password protecting. I am very new to VBA and found this code on line which has been a big help.
Thx in advance.
Josh