Password Protect Running of Macro

  • Thread starter Thread starter John
  • Start date Start date
J

John

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
 
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
 
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
 
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
 
How would one set up the routine to provide a usertform rather than an input
box then?

Gazza
 

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