How can I trap this Vlookup error in a VBA macro
On 8 Apr 2006 01:50:15 -0700, "Bondi" wrote:
Hi Richard,
In another thread some time ago i found that VLookup() produces a
runtime error when the value can not be found. You can use the
following to snap that event.
Code:
On Error Resume Next
'VLookUp()
If Err.Number < 0 Then
'If not found
Debug.Print Err.Number
Debug.Print Err.Description
Else
' If found
End If
On Error Goto ErorrHndl
Regards,
Bondi
Hi Bondi
Thanks for that suggestion, I hadn't thought of trapping the error
number and using that - rather neat.
It also avoids the problem of forcing the program flow to an error
handler, which by definition is outside any Looping part of the
Procedure.
Regards
PS, thanks also to the others who responded.
__
Richard Buttrey
Grappenhall, Cheshire, UK
__________________________
|