LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 296
Default 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
__________________________


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
I want to trap an error I get in a macro Mary Excel Programming 2 March 31st 06 10:45 PM
Error Handling - On Error GoTo doesn't trap error successfully David Excel Programming 9 February 16th 06 05:59 PM
Error Trap Kirk P. Excel Programming 2 September 8th 05 09:51 PM
error trap Rhonda[_3_] Excel Programming 2 October 22nd 03 07:07 PM


All times are GMT +1. The time now is 03:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"