ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Password required before Macro execution (https://www.excelbanter.com/excel-discussion-misc-queries/11558-password-required-before-macro-execution.html)

Andy Tallent

Password required before Macro execution
 
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.
--
Andy Tallent

eluehmann

Sub password()
CC = InputBox("Please enter the password:")
If CC = "password" Then
'PUT MACRO HERE
MsgBox ("Macro Execution")
End If
End Sub

"Andy Tallent" wrote in message
...
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.
--
Andy Tallent




JE McGimpsey

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



In article ,
Andy Tallent wrote:

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.


Andy Tallent

Thank you very much for this, it works perfectly.

Regards

Andy Tallent

"eluehmann" wrote:

Sub password()
CC = InputBox("Please enter the password:")
If CC = "password" Then
'PUT MACRO HERE
MsgBox ("Macro Execution")
End If
End Sub

"Andy Tallent" wrote in message
...
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.
--
Andy Tallent





Andy Tallent

Thank you, this works beautifully.

"JE McGimpsey" wrote:

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



In article ,
Andy Tallent wrote:

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.




All times are GMT +1. The time now is 01:29 AM.

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