Password required before Macro execution

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

Guest

What I would like to do is have a password box appear prior to a macro
executing. In the example I'm citing I have a macro keying off a
CommandButton but I don't want all users to be able to execute this macro,
only those with the password. Is this possible.

As always I am appreciative of your patience.
 
Sub password()
CC = InputBox("Please enter the password:")
If CC = "password" Then
'PUT MACRO HERE
MsgBox ("Macro Execution")
End If
End Sub
 
One way:

At the beginning of your macro, put something like

Const sPASSWORD As String = "drowssap"
Dim vResponse As Variant
Do
vResponse = Application.InputBox("Enter the Password")
If vResponse = False Then Exit Sub 'User Cancelled
Loop Until vResponse = sPASSWORD
 
Thank you very much for this, it works perfectly.

Regards

Andy Tallent
 
Thank you, this works beautifully.

JE McGimpsey said:
One way:

At the beginning of your macro, put something like

Const sPASSWORD As String = "drowssap"
Dim vResponse As Variant
Do
vResponse = Application.InputBox("Enter the Password")
If vResponse = False Then Exit Sub 'User Cancelled
Loop Until vResponse = sPASSWORD
 

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

Back
Top