zoom38
07-20-2006, 07:25 PM
I use the sub below that mdmackillop created to protect and unprotect my sheets so code will run. Now I want to password protect the sheets. If I protect the sheet with "pword" as my password and then activate the sub below, it works fine, it unprotects the sheets using the password. The problem lies when the sub protects the sheets, it will not protect the sheets with a password. I want the sheets to be password protected all of the time. I can't figure it out. Any ideas?
Sub DoProtect(x As Boolean)
For Each Sh In Worksheets
If x = False Then Sh.Unprotect password:="pword"
If x = True Then Sh.Protect password:="pword"
Next
End Sub
Thanks
Gary
Sub DoProtect(x As Boolean)
For Each Sh In Worksheets
If x = False Then Sh.Unprotect password:="pword"
If x = True Then Sh.Protect password:="pword"
Next
End Sub
Thanks
Gary