VBA VLOOKUP when search value NOT FOUND

MPastor

Board Regular
Joined
Apr 8, 2004
Messages
136
I'm having a problem using VLOOKUP in VBA when the search value is "NOT FOUND". When this condition occurs, my macro issues Run-Time Error '13': Type Mismatch.

My code is as follows:
Code:
  vItemShortDesc = Application.VLookup(vCell.Value, Sheets("ITM").Range("C:D"), 2, False)
Any suggestions on how to program for and "handle" this Not Found condition???
 

Some videos you may like

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

acw

MrExcel MVP
Joined
Feb 13, 2004
Messages
4,814
Mike

One way
Code:
Sub xxx()
 holder = ""
 On Error Resume Next
 holder = WorksheetFunction.VLookup("a", Range("a1:b3"), 2, False)
 On Error GoTo 0
 MsgBox holder
End Sub


Tony
 

Watch MrExcel Video

Forum statistics

Threads
1,118,081
Messages
5,570,088
Members
412,310
Latest member
mark884
Top