Skip to content

Instantly share code, notes, and snippets.

Created July 22, 2017 13:55
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Sub protect_all_sheets()
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
For Each s In ActiveWorkbook.Worksheets
s.Protect Password:=pass
Exit Sub
oops: MsgBox "I think you have some sheets that are already protected. Please unprotect all sheets then running this Macro."
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment