Sub test()
If ActiveSheet.ProtectContents Then
MsgBox "This sheet is protected"
Else
MsgBox "This sheet is unprotected"
End If
End Sub
--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2000 & 97
** remove news from my email address to reply by email **
Excellent. Thanks to all who posted. I came up with this......
Sub Master()
If ActiveSheet.ProtectContents Then
On Error Resume Next
Dim strWrongPasswordMsg As String
Do
Pwd = InputBox(strWrongPasswordMsg & "Please enter password t
unprotect this sheet....")
If Pwd = "" Then
Cancel = True
Exit Do
Else
Err.Clear
Sheets("AOct").Unprotect Pwd
If Err.Number = 0 Then
Exit Do
End If
strWrongPasswordMsg = "Invalid password." & vbCrLf & vbCrLf
End If
Loop
Else
If Pwd <> "" Then
Sheets("AOct").Protect Pwd
MsgBox "Worksheet is now protected. Thankyou"
End If
End If
End Sub
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.