Tennisball
New Member
- Joined
- Aug 2, 2010
- Messages
- 5
I have created a macro to protect a tab/sheet with a password. I am wondering how I can modify the macros so that once the password is entered correctly the first time, the macro does not keep asking to enter a password. I want it so that it only gets prompted the first time the sheet is activated and when the password is entered incorrectly. Any ideas?
Private Sub Worksheet_Activate()
Dim Password
Password = Application.InputBox("Please enter a valid password.")
If Password <> "pword" Then
MsgBox "This is not for you to view, please do not try to access this sheet!"
Sheets("Sheet1").Select
If pword <> "pword" Then Sheets("Sheet2").Visible = False
Else
ActiveSheet.Unprotect Password
End If
End Sub
Private Sub Worksheet_Activate()
Dim Password
Password = Application.InputBox("Please enter a valid password.")
If Password <> "pword" Then
MsgBox "This is not for you to view, please do not try to access this sheet!"
Sheets("Sheet1").Select
If pword <> "pword" Then Sheets("Sheet2").Visible = False
Else
ActiveSheet.Unprotect Password
End If
End Sub