-
Solved: Protecting Sheets With a Password
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?
[VBA]
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
[/VBA]
Thanks
Gary
-
Gary
Worked for me. Protected the sheets and I could unprotect manually using pword.....
Tony
-
Hello again Tony, my mistake. My sub calls another sub that unlocks the sheets and does not password protect. I threw on the password and it works. Thanks for loooking at it.
Gary
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules