Password on clicking button


I have a button where users can click it, it runs a sub and it clears some data onto a log, i want to run a password through that so that only certain users can clear the log,

how can i run a password through?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Glenn RayExcel VBA DeveloperCommented:
You can just add an input box to your code that prompts for and checks against a defined password:
    pword = Application.InputBox("Enter password to clear log", "PASSWORD REQUIRED")
    If pword = "PASSWORD" Then
        'statements that clear the log
    End If

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Andrew VelascoOperational Account Management & Data AnalystCommented:

You could make a userform with a textbox.  In the textbox properties, change the PasswordChar value to "*", making the password text not readable to others.  (Make sure to include a "Submit" and "Cancel" button.  Then when the user clicks the button have it call the userform, enter the password, hide the userform and reference the password text box:
Public strPassword as String

     strPassword = MyUserForm.PasswordTextBox.Value

     If strPassword = "YourPassWord" Then
          Your Code
     End If
End Sub

Open in new window

More on UserForms
Seamus2626Author Commented:
Thanks guys!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.