ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Passwords on macros's (https://www.excelbanter.com/excel-programming/282791-passwords-macross.html)

Kathy[_6_]

Passwords on macros's
 
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

Paul B[_7_]

Passwords on macros's
 
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" wrote in message
...
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



Paul B[_7_]

Passwords on macros's
 
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 **

"Paul B" wrote in message
...
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" wrote in message
...
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






All times are GMT +1. The time now is 12:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com