View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default On Error Resume Next

The easy way is this approach:


dim ans4 as Variant

ans4 = Application.VLookup(Range("C2"),Range("B6:D2000"), 3, False)

If iserror(ans4) Then
ans4 = "Value Not Defined"
End If

..Offset(1, 15).Value = ans4

--
Regards,
Tom Ogilvy



"Dan" wrote in message
...
I am using an VLookup and want to execute a specific action if the value is
not returned.

ans4 =
Application.WorksheetFunction.VLookup(Range("C2"), Range("B6:D2000"),
3, False)
On Error Resume Next

If "AN ERROR HAS OCCURRED" Then
ans4 = "Value Not Defined"
End If

.Offset(1, 15).Value = ans4

How do I do this?

Thanks