Subject pretty much says it all, I need to be able to protect & unprotect 31 sheets in a workbook, but I also need it to ask for a password to unprotect.
For Each wks In ThisWorkbook.Worksheets
wks.Protect "mypassword"
Next
End Sub
Sub eatme()
Dim wks As Worksheet, strPassword As String, blnError As Boolean
strPassword = InputBox("What's the password?")
If strPassword = "" Then Exit Sub
On Error Resume Next
blnError = False
For Each wks In ThisWorkbook.Worksheets
wks.Unprotect strPassword
If Err Then
MsgBox "Password incorrect", vbExclamation
blnError = True
Exit For
End If
Next
If Not blnError Then MsgBox "Done!", vbInformation
End Sub
Rob
pkley said:
Subject pretty much says it all, I need to be able to protect & unprotect
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.