Password protect my macro


Posted by Chris Rock on August 03, 2001 12:12 PM

I'd like a password prompt to come up when a macro button is pushed, and ask the user to try again if the wrong password is entered, up to 3 times.

Can someone demostrate code to do this? Is the "up to 3 times" part possible?



Posted by Malc on August 03, 2001 12:35 PM

Sub GetPassword
Dim Response as string, X as integer

for x = 1 to 3
Response = inputbox("Enter your password","Password")
if response = "The Password" then
runanothermacro
exit sub
end if
if X=3 then
Response = msgbox("Not the right password",VBCritical,"Password")
end if
next x
end sub
There's a way of making *** come up in the imput box check the help. Don't have excel at home to test it but either it or something like it will work