NutCase
Board Regular
- Joined
- Dec 10, 2004
- Messages
- 60
I have a Userform on which there are two comboboxes and a label. I want the user to be able to select from either the job name (combobox1) or a job number (combobox2). When either combobox is selected, I need the relevant data displayed in both comboboxes and the label. I have the following code below:
This is giving me an error message:
Run-time error '1004'
Unable to get the VLookup property of the WorksheetFunction class
I'm guessing this may be to do with having two change events that relate to the same Comboboxes?
Code:
Private Sub ComboBox1_Change()
Dim MyValue As String
Dim MyLookup As Double
MyValue = ComboBox1.Value
Label1 = Application.WorksheetFunction.VLookup(MyValue, Worksheets("JobList").Range("A2:C65536"), 2, False)
ComboBox2 = Application.WorksheetFunction.VLookup(MyValue, Worksheets("JobList").Range("A2:c65536"), 3, False)
End Sub
Private Sub ComboBox2_Change()
Dim MyValue As String
Dim MyLookup As Double
MyValue = ComboBox2.Value
Label1 = Application.WorksheetFunction.VLookup(MyValue, Worksheets("JobList").Range("A2:C65536"), 2, False)
ComboBox1 = Application.WorksheetFunction.VLookup(MyValue, Worksheets("JobList").Range("A2:c65536"), 1, False)
End Sub
This is giving me an error message:
Run-time error '1004'
Unable to get the VLookup property of the WorksheetFunction class
I'm guessing this may be to do with having two change events that relate to the same Comboboxes?