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.
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
How much do you know about VBA? Do you know how to open the VBA editor? Have you ever written any VBA code?
 
Upvote 0
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.
 
Upvote 0
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.
 
Upvote 0
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.
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,213,561
Messages
6,114,317
Members
448,564
Latest member
ED38

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top