?
Solved

Password on clicking button

Posted on 2014-08-19
3
Medium Priority
?
138 Views
Last Modified: 2014-08-20
Hi,

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?

thanks
0
Comment
Question by:Seamus2626
3 Comments
 
LVL 27

Accepted Solution

by:
Glenn Ray earned 1000 total points
ID: 40270703
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


Regards,
-Glenn
0
 
LVL 2

Assisted Solution

by:Andrew Velasco
Andrew Velasco earned 1000 total points
ID: 40271019
Hello,

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

ButtonPressedSub()
     MyUserForm.Show
     strPassword = MyUserForm.PasswordTextBox.Value

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

Open in new window


More on UserForms http://msdn.microsoft.com/en-us/library/office/gg264663(v=office.15).aspx
0
 

Author Closing Comment

by:Seamus2626
ID: 40271951
Thanks guys!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question