Password Protecting/Unprotecting Via Code
Private Sub Worksheet_Activate()
ans = Inputbox("enter password")
if lcase(ans) < "mypasswordinlowercase" then exit sub
ActiveSheet.Unprotect
Rows("2:5000").Select
Selection.EntireRow.Hidden = False
Range("F1").Select
End Sub
--
Regards,
Tom Ogilvy
"MWS" wrote in message
...
I have a worksheet that has hidden rows and I'd like to write the code so
upon the user activating the worksheet, they are prompted for a password
and....
If the correct password is enterred, the rows become unhidden (that part
is
not a problem).
And, if either an incorrect password OR the user selects "cancel" at the
password prompt, the process is aborted and the user is simply returned to
the worksheet and the rows remain unhidden (this section is my problem).
Currently, if the user inputs an incorrect password OR selects cancel, the
code fails.
The code I have is as follows:
Private Sub Worksheet_Activate()
ActiveSheet.Unprotect
Rows("2:5000").Select
Selection.EntireRow.Hidden = False
Range("F1").Select
End Sub
Can someone help by providing the additional code so the process executes
as
desired?
Any and all help is appreciated - Thank You
|