Passwords on macros's

K

Kathy

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
 
P

Paul B

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
 
P

Paul B

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 **
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top