LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   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

Hi,

I have a need to identify whether a Job Number appears in a specific
range, and take different actions in a mcaro dependent on whether it
is or isn't present.

As a function this would simply be

=If(Iserror( Vlookup(x,MyRange,1,false)),"This","That")

However I'm having difficulties building this into a macro using
Application.WorksheetFunction. I keep stumbling on the 'Unable to get
the Vlookup property of the Worksheet Function Class" where the job
number doesn't exist

I've also tried MyRange.Find(what:=JobNo, after ............etc.,
but get the 'Object Variable with Block Variable not set' error, where
the jobs doesn't exist.

How can I construct an

If "JobNo exists" Then
"This"
else
"That"
End If

test?


Usual TIA

__
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 05:20 PM.

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

About Us

"It's about Microsoft Excel"