Passwords on macros's

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to set up a button that runs a macro, but I want the user to be prompted to key in a password so that only certain users can run macro
 
Kathy, use something like this

Sub Password_To_Run()
Dim PW As String
PW = Application.InputBox( _
Prompt:="Please Enter The Password", _
Title:="Password Required To Run This Macro", _
Type:=2)
If PW = "abc" Then ''The password is CASE sensitive

'''*****Your Code Here*****

Else
'''****If Password Is Incorrect*********
MsgBox Prompt:="Sorry, That Is Not The Correct Password", _
Title:="Incorrect Password", _
Buttons:=vbOKOnly

End If
End Sub
--
Paul B
Always backup your data before trying something new
Using Excel 97 & 2000
Please post any response to the newsgroups so others can benefit from it
** remove news from my email address to reply by email **


Kathy said:
I want to set up a button that runs a macro, but I want the user to be
prompted to key in a password so that only certain users can run macro
 
You must also lock the VBA project so you can't see the password in it

--
Paul B
Always backup your data before trying something new
Using Excel 97 & 2000
Please post any response to the newsgroups so others can benefit from it
** remove news from my email address to reply by email **
 
Back
Top