![]() |
Vlookup What if not Found
How do I make this code not error if the value in cboCarPartModel is
not found in my wo worksheet? It works fine if the value is found but errors if not found. Jody Private Sub cboCarPartModel_Change() Dim wo As Range Set wo = Worksheets("cpModels").Range("cpModelNameAndNumber s") If Me.cboCarPartModel.Value "" Then Label3.Caption = Application.VLookup(cboCarPartModel.Value, wo, 2, False) End If End Sub |
Vlookup What if not Found
Hi SS,
One way: Private Sub cboCarPartModel_Change() Dim wo As Range Set wo = Worksheets("cpModels").Range("cpModelNameAndNumber s") If Me.cboCarPartModel.Value "" Then On Error Resume Next Label3.Caption = _ Application.VLookup(cboCarPartModel.Value, wo, 2, False) If Err.Number < 0 Then MsgBox "Not found!" On Error GoTo 0 End If End Sub --- Regards, Norman "ssjody" wrote in message oups.com... How do I make this code not error if the value in cboCarPartModel is not found in my wo worksheet? It works fine if the value is found but errors if not found. Jody Private Sub cboCarPartModel_Change() Dim wo As Range Set wo = Worksheets("cpModels").Range("cpModelNameAndNumber s") If Me.cboCarPartModel.Value "" Then Label3.Caption = Application.VLookup(cboCarPartModel.Value, wo, 2, False) End If End Sub |
Vlookup What if not Found
Thanks Norman! Works Great!
|
All times are GMT +1. The time now is 07:05 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com