Using VLOOKUP in VBA with userform and combobox
I get an error (actually two)
1) See error on msgbox
2) on the VLOOKUP lines I get "Compile error Expected: list separator or )"
I want to populate fields base on the selection from combobox
Code below:
Private Sub Combo_WO_ADD_Change()
Dim WONo As Integer
If Me.Combo_WO_ADD.Value = “” Then
' SEE ERROR Showing this line
MsgBox “WO No Can Not be Blank!!!”, vbExclamation, “WO No”
Exit Sub
End If
WONo = Combo_WO_ADD.Value
On Error Resume Next
' SEE ERROR Showing the following 14 lines
Me.text_Created.Value = Application.WorksheetFunction.VLookup(WONo, Sheets(“data”).Range(“C5:Q10000”), 2, 0)
Me.combo_location.Value = Application.WorksheetFunction.VLookup(WONo, Sheets(“data”).Range(“C5:Q10000”), 3, 0)
Me.combo_Status.Value = Application.WorksheetFunction.VLookup(WONo, Sheets(“data”).Range(“C5:Q10000”), 4, 0)
Me.text_CDate.Value = Application.WorksheetFunction.VLookup(WONo, Sheets(“data”).Range(“C5:Q10000”), 5, 0)
Me.text_mechanic.Value = Application.WorksheetFunction.VLookup(WONo, Sheets(“data”).Range(“C5:Q10000”), 6, 0)
Me.combo_Category.Value = Application.WorksheetFunction.VLookup(WONo, Sheets(“data”).Range(“C5:Q10000”), 7, 0)
Me.combo_permits.Value = Application.WorksheetFunction.VLookup(WONo, Sheets(“data”).Range(“C5:Q10000”), 8, 0)
Me.combo_tag.Value = Application.WorksheetFunction.VLookup(WONo, Sheets(“data”).Range(“C5:Q10000”), 9, 0)
Me.text_item.Value = Application.WorksheetFunction.VLookup(WONo, Sheets(“data”).Range(“C5:Q10000”), 10, 0)
Me.text_subgroup.Value = Application.WorksheetFunction.VLookup(WONo, Sheets(“data”).Range(“C5:Q10000”), 11, 0)
Me.text_issue.Value = Application.WorksheetFunction.VLookup(WONo, Sheets(“data”).Range(“C5:Q10000”), 12, 0)
Me.text_Repair.Value = Application.WorksheetFunction.VLookup(WONo, Sheets(“data”).Range(“C5:Q10000”), 13, 0)
Me.text_time = Application.WorksheetFunction.VLookup(WONo, Sheets(“data”).Range(“C5:Q10000”), 14, 0)
Me.text_cost.Value = Application.WorksheetFunction.VLookup(WONo, Sheets(“data”).Range(“C5:Q10000”), 15, 0)
End Sub
I get an error (actually two)
1) See error on msgbox
2) on the VLOOKUP lines I get "Compile error Expected: list separator or )"
I want to populate fields base on the selection from combobox
Code below:
Private Sub Combo_WO_ADD_Change()
Dim WONo As Integer
If Me.Combo_WO_ADD.Value = “” Then
' SEE ERROR Showing this line
MsgBox “WO No Can Not be Blank!!!”, vbExclamation, “WO No”
Exit Sub
End If
WONo = Combo_WO_ADD.Value
On Error Resume Next
' SEE ERROR Showing the following 14 lines
Me.text_Created.Value = Application.WorksheetFunction.VLookup(WONo, Sheets(“data”).Range(“C5:Q10000”), 2, 0)
Me.combo_location.Value = Application.WorksheetFunction.VLookup(WONo, Sheets(“data”).Range(“C5:Q10000”), 3, 0)
Me.combo_Status.Value = Application.WorksheetFunction.VLookup(WONo, Sheets(“data”).Range(“C5:Q10000”), 4, 0)
Me.text_CDate.Value = Application.WorksheetFunction.VLookup(WONo, Sheets(“data”).Range(“C5:Q10000”), 5, 0)
Me.text_mechanic.Value = Application.WorksheetFunction.VLookup(WONo, Sheets(“data”).Range(“C5:Q10000”), 6, 0)
Me.combo_Category.Value = Application.WorksheetFunction.VLookup(WONo, Sheets(“data”).Range(“C5:Q10000”), 7, 0)
Me.combo_permits.Value = Application.WorksheetFunction.VLookup(WONo, Sheets(“data”).Range(“C5:Q10000”), 8, 0)
Me.combo_tag.Value = Application.WorksheetFunction.VLookup(WONo, Sheets(“data”).Range(“C5:Q10000”), 9, 0)
Me.text_item.Value = Application.WorksheetFunction.VLookup(WONo, Sheets(“data”).Range(“C5:Q10000”), 10, 0)
Me.text_subgroup.Value = Application.WorksheetFunction.VLookup(WONo, Sheets(“data”).Range(“C5:Q10000”), 11, 0)
Me.text_issue.Value = Application.WorksheetFunction.VLookup(WONo, Sheets(“data”).Range(“C5:Q10000”), 12, 0)
Me.text_Repair.Value = Application.WorksheetFunction.VLookup(WONo, Sheets(“data”).Range(“C5:Q10000”), 13, 0)
Me.text_time = Application.WorksheetFunction.VLookup(WONo, Sheets(“data”).Range(“C5:Q10000”), 14, 0)
Me.text_cost.Value = Application.WorksheetFunction.VLookup(WONo, Sheets(“data”).Range(“C5:Q10000”), 15, 0)
End Sub
Last edited: