Lauren Thomas
New Member
Hello
I am trying to write a macro to lock a workbook that has multiple worksheets as it takes a lot of time to lock the worksheets manually.
I found this by googling and it seems to work well.
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
However I would also like users to be able to insert comments onto all of the worksheets so I am trying to edit the above code to include code that allows the use of 'Edit Objects'
Are you able to help?
Many thanks
Lauren
▬▬▬▬▬▬▬▬▬ Mod edit : thread moved to appropriate forum !
I am trying to write a macro to lock a workbook that has multiple worksheets as it takes a lot of time to lock the worksheets manually.
I found this by googling and it seems to work well.
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
However I would also like users to be able to insert comments onto all of the worksheets so I am trying to edit the above code to include code that allows the use of 'Edit Objects'
Are you able to help?
Many thanks
Lauren
▬▬▬▬▬▬▬▬▬ Mod edit : thread moved to appropriate forum !