Prompt password for each selection from a listbox

pwebley

Board Regular
Joined
Mar 2, 2011
Messages
69
I have a list box that is filled with employees names. I want the user to be able to select their name and be prompted for a password that is specific for them. I only have the list box at this point so any help will be appreciated.
 

Some videos you may like

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Ruddles

Well-known Member
Joined
Aug 24, 2010
Messages
5,785
How much do you know about VBA? Do you know how to open the VBA editor? Have you ever written any VBA code?
 

Ruddles

Well-known Member
Joined
Aug 24, 2010
Messages
5,785
Excellent. Is it a list box on a userform, a list box on your worksheet or a cell with data validation? The three things all behave differently.
 

pwebley

Board Regular
Joined
Mar 2, 2011
Messages
69

ADVERTISEMENT

This is a list box on a userform.
 

Ruddles

Well-known Member
Joined
Aug 24, 2010
Messages
5,785
Listboxes on userforms have change events. Right-click the listbox in design mode and go View Code. Select your listbox from the left-hand drop-down and Change from the right-hand one.

This will generate the skeleton code for your listbox's change event. Now you have to think of a way of checking passwords and write the code to do that.

Incidentally, are you aware that Environ("username") will return the username currently logged in? If it's suitable for your purposes, rather than ask the user to select his name from a listbox, you might consider just checking that instead. He would have had to get through the Windows login so he would have supplied a password at that point.
 

pwebley

Board Regular
Joined
Mar 2, 2011
Messages
69

ADVERTISEMENT

Great thank you for the help. The user will not be the same as the "user name" logged in. The program will be running in a guest account. Now I just need to figure out how to write the code to specify a password for each name on the list and have it ask for their password when they select it to clock in. When the enter the correct password I want a time stamp put in a specific place for payroll purposes.
 

Ruddles

Well-known Member
Joined
Aug 24, 2010
Messages
5,785
Do you intend to allocate a password for each of the entries in the listbox?

If so, you could keep them in the worksheet column next to the entries which you used to load the listbox, then use VLOOKUP to retrieve the password for the selected listbox value and compare it to what the user types in.

The worksheet containing the passwords should have its visibility set to xlVeryHidden to keep it safe from prying eyes.
 

pwebley

Board Regular
Joined
Mar 2, 2011
Messages
69
That is my intentions. Thank you for the tips. I will give that a try.
 

Watch MrExcel Video

Forum statistics

Threads
1,108,624
Messages
5,523,968
Members
409,547
Latest member
AW2020

This Week's Hot Topics

Top