Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
PASSWORD PROMPTING CODE
I have assigned a macro code to a command button in Excel. I need a
macro code to add to my original code that will prompt any user that pushes the button to enter a password before the code assigned to the button executes. Any assistance will be appreciated.Thanks! Jay Dean. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
PASSWORD PROMPTING CODE
Jay, how about something like this
Sub PassWord_for_Macro() 'must lock VBA project so you can't see the password in it Dim MyStr1 As String, MyStr2 As String With ActiveSheet MyStr2 = ("123") 'change to your password MyStr1 = InputBox("Password Is Required To Run this Macro ") If MyStr1 = MyStr2 Then '*******your code here******** Else MsgBox ("Password Does Not Match, Access Denied") End If End With End Sub -- Paul B Always backup your data before trying something new Using Excel 2000 & 97 Please post any response to the newsgroups so others can benefit from it ** remove news from my email address to reply by email ** "Jay Dean" wrote in message om... I have assigned a macro code to a command button in Excel. I need a macro code to add to my original code that will prompt any user that pushes the button to enter a password before the code assigned to the button executes. Any assistance will be appreciated.Thanks! Jay Dean. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
PASSWORD PROMPTING CODE
Jay,
This code uses a simple InputBox to query the user for a password. Troy Sub RequestPassword() Dim sReply As String sReply = Application.InputBox( _ Prompt:="Please enter the password", _ Title:="Password Required", _ Type:=2) If sReply = "thePassword" Then '''Run the password protected code. MsgBox sReply & " is the correct password" Else '''Do not run the password protected code. MsgBox "Sorry, incorrect password" End If End Sub "Jay Dean" wrote in message om... I have assigned a macro code to a command button in Excel. I need a macro code to add to my original code that will prompt any user that pushes the button to enter a password before the code assigned to the button executes. Any assistance will be appreciated.Thanks! Jay Dean. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
PASSWORD PROMPTING CODE
Thank you very much. It worked beautifully !!
Jay Dean "TroyW" wrote in message ... Jay, This code uses a simple InputBox to query the user for a password. Troy Sub RequestPassword() Dim sReply As String sReply = Application.InputBox( _ Prompt:="Please enter the password", _ Title:="Password Required", _ Type:=2) If sReply = "thePassword" Then '''Run the password protected code. MsgBox sReply & " is the correct password" Else '''Do not run the password protected code. MsgBox "Sorry, incorrect password" End If End Sub "Jay Dean" wrote in message om... I have assigned a macro code to a command button in Excel. I need a macro code to add to my original code that will prompt any user that pushes the button to enter a password before the code assigned to the button executes. Any assistance will be appreciated.Thanks! Jay Dean. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
remove password on VBA code | Excel Discussion (Misc queries) | |||
Put Password Protection in Code | Excel Discussion (Misc queries) | |||
Include a password in VB code. | Excel Discussion (Misc queries) | |||
How to see macro code of a password protected macro without a password? | Excel Worksheet Functions | |||
password protect vba code | Excel Discussion (Misc queries) |