Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi, I have a userform with a Combobox with names.
Below this are some fields like Date of birth: Nationality: This data is stored in a worksheet and a vlookup on the name selected in the combobox should be able to retrieve data to populate the textboxes in the userform. Also, I suppose there should be a button the user has to click after selecting a name from the combobox. Would anyone know how to do this vlookup in VBA and populate the textboxes? Any help greatly appriciated! |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Possibly something like this:
Private Sub Combobox1_Click() Dim rng as Range, r as Range, res as Variant With Worksheets("Data") set rng = .Range(.cells(2,"B"),.Cells(2,"B").End(xldown)) res = Application.Match(combobox1.Value,rng,0) if not iserror(res) then r = rng(res) Textbox1.Text = .Cells(r.row,"A") Textbox2.Text = .Cells(r.Row,"C") else msgbox Combobox1.Value & " was not found" end if end With End Sub Change the "B" to reflect the column letter where the Names are located and change "Data" to reflect the sheet containing the data table. Make other changes as appropriate. -- Regards, Tom Ogilvy "Hendrik.Kleine" wrote: Hi, I have a userform with a Combobox with names. Below this are some fields like Date of birth: Nationality: This data is stored in a worksheet and a vlookup on the name selected in the combobox should be able to retrieve data to populate the textboxes in the userform. Also, I suppose there should be a button the user has to click after selecting a name from the combobox. Would anyone know how to do this vlookup in VBA and populate the textboxes? Any help greatly appriciated! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
vlookup shows result one cell above the expected result | Excel Worksheet Functions | |||
vlookup based on random result returns incorrect result | Excel Worksheet Functions | |||
Format of textbox on userform and correct result | Excel Programming | |||
textbox result to label | Excel Programming | |||
UserForm TextBox to ActiveSheet TextBox over 256 characters | Excel Programming |