Help with using Index/Match via VBA

Sabotage

Board Regular
Joined
Sep 19, 2013
Messages
58
Hey guys,
I wonder if anyone can understand and also help me with the following. I use a userform to log user's (employees) start time by login with a 4 digit PIN into the application. If PIN don't match user will be prompted to try again or exit. This is to prevent employees from entering unwanted start times for others. The employees don't need to type or pick their names (to avoid long waitings) instead they will type a unique employee ID assigned upon hiring. I have a ComboBox with a RowSource attached to pick or type this employee ID.​

After the ComboBox is updated I am still displaying their full name in a TextBox item to make sure they are doing the right thing. If their name don't appear in the TextBox, they have the opportunity to change the employee ID. This is where my problem starts, up to employee ID 47 (e.g. PFO-0047, where the "PFO-" value in the ComboBox is default) the implemented index/match function finding the correspondent name is working just fine, but as soon as the ID "PFO-0048" is picked or typed the corresponding name does not match. Infact whatever is picked in the ComboBox after 0047 ID the correspondent name becomes the very last name in the list every time. Always the very last name in the list. The list is a dynamic named range.​

What you might also need to know if willing to save me from this misery is that the current list of employees have 2 different prefixes in their Employee ID, the last PFO number is 0050 then the list continues with IDs like PFF-0001 (different pay grade employees)

Please help if you can, many many thanks in advance...​

Code:
Private Sub cb_Alk_Szam_AfterUpdate() 'cb_Alk_Szam is the ComboBox for employee ID picking
    FullNam = WorksheetFunction.Index(Range("Alk_Nev"), WorksheetFunction.Match(cb_Alk_Szam, Range("Alk_Szam")), 0)
    tb_FullName.Value = FullNam
    tb_PIN.SetFocus
End Sub
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Forum statistics

Threads
1,215,788
Messages
6,126,907
Members
449,348
Latest member
Rdeane

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