TBS2766
03-17-2011, 11:13 AM
I am new to VBA and am trying to write a code that when someone clicks on the checkbox it prompts for a password. If password is false I want the checkbox to remain unchecked and a msgbox to appear saying not authorized. If password is true then the checkbox would be checked and a macro would run. I have experimented with the code and have managed to do everything expect have to checkbox remain unchecked if incorrect password is given. Can someone help me with just this step?:help
This is the half of the code I have come up with through trial and error for an incorrect password:
Sub CheckBox1_Click()
Dim myPWD As String
Dim userPWD As String
myPWD = "123"
userPWD = InputBox(Prompt:="Password")
If userPWD <> myPWD Then
MsgBox "Not Authorized"
Exit Sub
End If
End Sub
This is the half of the code I have come up with through trial and error for an incorrect password:
Sub CheckBox1_Click()
Dim myPWD As String
Dim userPWD As String
myPWD = "123"
userPWD = InputBox(Prompt:="Password")
If userPWD <> myPWD Then
MsgBox "Not Authorized"
Exit Sub
End If
End Sub