Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default 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!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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!

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
vlookup shows result one cell above the expected result Marie Excel Worksheet Functions 7 November 14th 06 02:52 AM
vlookup based on random result returns incorrect result rickat Excel Worksheet Functions 1 December 6th 05 01:16 PM
Format of textbox on userform and correct result Mark Excel Programming 1 July 13th 04 02:49 PM
textbox result to label paradise Excel Programming 2 November 15th 03 01:10 PM
UserForm TextBox to ActiveSheet TextBox over 256 characters Dan E[_2_] Excel Programming 1 July 28th 03 07:36 PM


All times are GMT +1. The time now is 01:21 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"