VBA VLOOKUP AND No Value Match
Taken from my first post and modified:
Option Explicit
Sub ZOO2()
Dim res As Variant
With ActiveSheet
res = Application.VLookup(.Range("A2").Value, _
Worksheets("Sheet1").Range("A2:C4"), 2, 0)
If IsError(res) Then
.Cells(5, 8).Value = "" 'CVErr(xlErrNA)
Else
.Cells(5, 8).Value = res
End If
End With
End Sub
I changed this line:
..Cells(5, 8).Value = CVErr(xlErrNA)
to
..Cells(5, 8).Value = "" 'CVErr(xlErrNA)
(the cverror() stuff is commented out.)
JimFor wrote:
I finally was able to get "N/A" placed in a cell when an account number which
appeared on sheet 2 did not appear on sheet 1. Read in a book that at times
"WorksheetFunction.VLookup" does not work correctly and if that happens one
should try using "Application.VLookup." When I used that code, the program
worked. However, I still cannot get the program to insert a blank instead of
"N/A". I am getting another error message and have posed my question under the
"VLOOKUP Compile/Syntax Error" thread.
Thanks for your help.
--
Dave Peterson
|