Need popup for password

S

SMILE

Hi Everyone
I need to run a macro to popup a window to enter a password with tw
buttons "OK" and "CANCEL"

Then I need to put a condition that

If the password is correct then

Application.Run "'DATA.xls'!CLEARDATA"

can someone help me???
Thanks in Advance
Tom
 
D

Dave O

....and the rest of the question is "How can I hide or mask the VBA
code so an informed user can't hack the password?"
 
D

Dave Peterson

If you want to hide the password while the user is typing, you'll need a
Userform to mask the characters typed.

But if it's ok to see the password:

Option Explicit
Sub testme()

Dim myPWD As String

myPWD = InputBox(Prompt:="What's the password, Kenny?")

If myPWD = "ThisIsCorrect" Then
Application.Run "'DATA.xls'!CLEARDATA"
Else
MsgBox "nope"
End If

End Sub
 
Top