![]() |
UserForm VLOOKUP result in textbox
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! |
UserForm VLOOKUP result in textbox
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! |
All times are GMT +1. The time now is 11:39 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com