I have some employee Names on column "A" and employee Numbers on column "B" in sheet1. On userform I have a combobox that shows employee names,i want when a name is selected on combobox his/her employee Number shown on a nearby txtbox and i dont know how.
Me.cboNames
Me.txtEmployeeNumber
Something like this maybe (assuming your data is in sheet "Employee"):
If you like just to show the number, consider using a label instead of a textbox.
The code below will load all values to the
ComboBox
(without a loop) fromWorksheets("Sheet4")
(modify to your sheet's name). Afterwards, on the Combo-BoxChange
event it will modify the value in the text box.Note: If you have a header row, and you data starts from the 2nd row, modify the line below :
to:
Code (inside the
User_Form
module):'=========================================================================
This code works