Vlookup using ComboBox value

  • Thread starter Thread starter Patrick C. Simonds
  • Start date Start date
P

Patrick C. Simonds

Is there any way to get this to work?

ComboBox1 has an employee's name. Employee List is not the active worksheet.




If Range("$A$3") = "Monday" Then

TextBox4.Text = VLOOKUP(ComboBox1.Value,'Employee
List'!$A$4:$H$1000,3,FALSE)

End If
 
try creating a range name on that sheet and use it in the listbox code
instead and se if that works
TextBox4.Text = VLOOKUP(ComboBox1.Value,rngname,3,FALSE)
 
I get a Variable no defined error, and Employees is highlighted. Scope is
set to workbook. Here is my current code:


If Range("$A$3") = "Monday" Then
TextBox4.Text = VLookup(ComboBox1.Value, Employees, 3, False)

End If
 
I thought you were trying to set the rowsource of another sheet. but anyway
this woroks for me.

I set up a form with a combobox, 4 textboxes and a command button.
on sheet1 I created a range name employees, from i9:m12
names were listed in column I

I set the rowsource for the combobox to employees

when I loaded the form and clicked the command button, textbox4 filled in

Private Sub CommandButton1_Click()
Dim rng As Range
Set rng = Range("employees")
Me.TextBox4.Text = Application.VLookup(ComboBox1.Value, rng, 3, False)
End Sub
 
Thank you, that did the trick.




Gary Keramidas said:
I thought you were trying to set the rowsource of another sheet. but anyway
this woroks for me.

I set up a form with a combobox, 4 textboxes and a command button.
on sheet1 I created a range name employees, from i9:m12
names were listed in column I

I set the rowsource for the combobox to employees

when I loaded the form and clicked the command button, textbox4 filled in

Private Sub CommandButton1_Click()
Dim rng As Range
Set rng = Range("employees")
Me.TextBox4.Text = Application.VLookup(ComboBox1.Value, rng, 3, False)
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top