View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Jacob Skaria Jacob Skaria is offline
external usenet poster
 
Posts: 8,520
Default Use VLOOKUP to populate text box on form

Typo...
comboname is cboFuel1
textbox name is TextBox1

Private Sub cboFuel1_Change()
Me.TextBox1 = WorksheetFunction.VLookup(Me.cboFuel1, _
Worksheets("Data").Range("A:B"), 2, 0)
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Jacob Skaria" wrote:

Try the below which is the combo change event...which will lookup the
corresponding value in ColB and populate that to me.textbox1

Private Sub cboFuel1_Change()
Me.TextBox1 = WorksheetFunction.VLookup(Me.ComboBox1, _
Worksheets("Data").Range("A:B"), 2, 0)
End Sub


If this post helps click Yes
---------------
Jacob Skaria


"Greg Snidow" wrote:

Greetings everyone. I'm not sure if I can do this, but on a user form I have
a combo box that populates from a range on sheet 'DATA', with items. There
is also a text box that I want to find the price of that item. Thoretically,
assuming my data is such that item is in column A of 'DATA', starting at row
18, and price is in column B of 'DATA', how can I get the price of the item
selected from the combo box. I found a post by Dave Peterson to populate the
list of the combo, but I am at a loss as to how to populate the text box for
price. Any ideas? Below is the code to populate the list(thanks Dave).

Private Sub UserForm_Initialize()
With Worksheets("Data")
Me.cboFuel1.List = .Range("A18", .Cells(.Rows.Count,
"A").End(xlUp)).Value
End With

Greg