ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro-password (https://www.excelbanter.com/excel-programming/291807-macro-password.html)

DJ

Macro-password
 
Can you make a user enter a password before a macro will run, and if so how. I have tried everything I could think of but am not well-versed in VB. Thanks for your help.

Harald Staff

Macro-password
 
In its simplest form:

Sub test()
Dim PW As String
PW = "Janet"
If InputBox("Password") < PW Then Exit Sub
'Macro code here, like:
MsgBox "Thank you for choosing Linux Redhat", _
vbInformation, "Installation complete"
End Sub

--
HTH. Best wishes Harald
Followup to newsgroup only please.

"DJ" wrote in message
...
Can you make a user enter a password before a macro will run, and if so how. I have

tried everything I could think of but am not well-versed in VB. Thanks for your help.



DJ

Macro-password
 
Thank you for responding to my question. But I don't
understand part of it ---does this go at the beginning of
the code before my macro code....and where you have a
quote mark and Macro code here, like: am I supposed to put
something there??? Don't I need to put code in for the
inputbox like what cell to be clicked in for this to be
activated and the text like enter password?? I don't know
and need for this to be explained in detail if you don't
mind....thanks so much.

With the way I have it right now - I keep getting a
compile error saying expected: =
-----Original Message-----
In its simplest form:

Sub test()
Dim PW As String
PW = "Janet"
If InputBox("Password") < PW Then Exit Sub
'Macro code here, like:
MsgBox "Thank you for choosing Linux Redhat", _
vbInformation, "Installation complete"
End Sub

--
HTH. Best wishes Harald
Followup to newsgroup only please.

"DJ" wrote in

message
...
Can you make a user enter a password before a macro

will run, and if so how. I have
tried everything I could think of but am not well-versed

in VB. Thanks for your help.


.



All times are GMT +1. The time now is 06:25 PM.

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