![]() |
Password Protect Running of Macro
Is it possible to Password protect the running of a Macro
I have a Macro that I only want certain people to be able to Run, I have created the Macro but before it runs / executes I would like a dialog box to pop up with a required password input, If the password is incorrect the action is just cancelled Thanks |
Password Protect Running of Macro
Did a search of Groups and spotted this neat code to do what I require
Sub PasswordForAMacro() Dim Message As String, Title As String Dim MyValue As String Message = "Please enter your password to access this" Title = "Run Macro" MyValue = InputBox(Message, Title, Default) If MyValue < "1234" Then MsgBox "Invalid password - you cannot access this" Exit Sub Else 'type the actions / code you require to run' ActiveSheet.Range("A1").Select End If End Sub "John" wrote in message ... Is it possible to Password protect the running of a Macro I have a Macro that I only want certain people to be able to Run, I have created the Macro but before it runs / executes I would like a dialog box to pop up with a required password input, If the password is incorrect the action is just cancelled Thanks |
Password Protect Running of Macro
Is there an input mask that will enter the Password as **** instead of 1234?
I will be accessing this log on lineso a user in the remote location might see the password I type in "John" wrote in message ... Did a search of Groups and spotted this neat code to do what I require Sub PasswordForAMacro() Dim Message As String, Title As String Dim MyValue As String Message = "Please enter your password to access this" Title = "Run Macro" MyValue = InputBox(Message, Title, Default) If MyValue < "1234" Then MsgBox "Invalid password - you cannot access this" Exit Sub Else 'type the actions / code you require to run' ActiveSheet.Range("A1").Select End If End Sub "John" wrote in message ... Is it possible to Password protect the running of a Macro I have a Macro that I only want certain people to be able to Run, I have created the Macro but before it runs / executes I would like a dialog box to pop up with a required password input, If the password is incorrect the action is just cancelled Thanks |
Password Protect Running of Macro
I don't know a way, but I know a workaround Say the password was bob12, at the start of your subroutine you coul have the line If InputBox("Enter password") = "bob12" Then etc.... end if THis would prompt for a password. You would then have to protect you VBAProject to stop people seeing this -- r.bell321Posted from - http://www.officehelp.i |
Password Protect Running of Macro
You can't do that with an inputbox. You'd need a userform with a
textbox whose PasswordChar property set to "*". -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "John" wrote in message ... Is there an input mask that will enter the Password as **** instead of 1234? I will be accessing this log on lineso a user in the remote location might see the password I type in "John" wrote in message ... Did a search of Groups and spotted this neat code to do what I require Sub PasswordForAMacro() Dim Message As String, Title As String Dim MyValue As String Message = "Please enter your password to access this" Title = "Run Macro" MyValue = InputBox(Message, Title, Default) If MyValue < "1234" Then MsgBox "Invalid password - you cannot access this" Exit Sub Else 'type the actions / code you require to run' ActiveSheet.Range("A1").Select End If End Sub "John" wrote in message ... Is it possible to Password protect the running of a Macro I have a Macro that I only want certain people to be able to Run, I have created the Macro but before it runs / executes I would like a dialog box to pop up with a required password input, If the password is incorrect the action is just cancelled Thanks |
Password Protect Running of Macro
How would one set up the routine to provide a usertform rather than an input
box then? Gazza "Chip Pearson" wrote in message ... You can't do that with an inputbox. You'd need a userform with a textbox whose PasswordChar property set to "*". -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "John" wrote in message ... Is there an input mask that will enter the Password as **** instead of 1234? I will be accessing this log on lineso a user in the remote location might see the password I type in "John" wrote in message ... Did a search of Groups and spotted this neat code to do what I require Sub PasswordForAMacro() Dim Message As String, Title As String Dim MyValue As String Message = "Please enter your password to access this" Title = "Run Macro" MyValue = InputBox(Message, Title, Default) If MyValue < "1234" Then MsgBox "Invalid password - you cannot access this" Exit Sub Else 'type the actions / code you require to run' ActiveSheet.Range("A1").Select End If End Sub "John" wrote in message ... Is it possible to Password protect the running of a Macro I have a Macro that I only want certain people to be able to Run, I have created the Macro but before it runs / executes I would like a dialog box to pop up with a required password input, If the password is incorrect the action is just cancelled Thanks |
Password Protect Running of Macro
The original subroutine would have to read: Sub PasswordForAMacro() Userform1.Show End Sub You would need a userform (called Userform1) with a text box (calle Textbox1 with PasswordChar property set to "*") and a button (calle Button1) to submit the userform. Then put the following code in th userform Sub Button1_Click() If Textbox1.text < "1234" Then MsgBox "Invalid password - you cannot access this" Userform1.Hide Exit Sub Else 'type the actions / code you require to run' Userform1.Hide End I -- r.bell321Posted from - http://www.officehelp.i |
Password Protect Running of Macro
Thanks R.Bell, thats neat
"r.bell321" wrote in message ... The original subroutine would have to read: Sub PasswordForAMacro() Userform1.Show End Sub You would need a userform (called Userform1) with a text box (called Textbox1 with PasswordChar property set to "*") and a button (called Button1) to submit the userform. Then put the following code in the userform Sub Button1_Click() If Textbox1.text < "1234" Then MsgBox "Invalid password - you cannot access this" Userform1.Hide Exit Sub Else 'type the actions / code you require to run' Userform1.Hide End If -- r.bell321Posted from - http://www.officehelp.in |
Password Protect Running of Macro
Of course you had better password protect your code as well.
Jon "John" wrote in message ... Thanks R.Bell, thats neat "r.bell321" wrote in message ... The original subroutine would have to read: Sub PasswordForAMacro() Userform1.Show End Sub You would need a userform (called Userform1) with a text box (called Textbox1 with PasswordChar property set to "*") and a button (called Button1) to submit the userform. Then put the following code in the userform Sub Button1_Click() If Textbox1.text < "1234" Then MsgBox "Invalid password - you cannot access this" Userform1.Hide Exit Sub Else 'type the actions / code you require to run' Userform1.Hide End If -- r.bell321Posted from - http://www.officehelp.in |
All times are GMT +1. The time now is 10:10 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com