View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Fred Smith Fred Smith is offline
external usenet poster
 
Posts: 623
Default Worksheetfunction

Thanks, Chip. Exactly the information I needed.

--
Regards,
Fred
Please reply to newsgroup, not e-mail


"Chip Pearson" wrote in message
...
Fred,

It depends on how you want error handling to occur, and by
extension, how you have declared the result variable.

If you omit the Worksheet function portion of the syntax, and
VLOOKUP fails, an error subtype variant is returned from the
function. If the result variable is not defined as a Variant,
you'll receive an error 13 - Type Mismatch (error trapping code
should be in place to handle this). If the return variable is in
fact declared as a Variant, it will contain an error value, and
you can test for this with IsError.

If you include the Worksheet function portion of the syntax, and
VLOOKUP fails, an error (1004) is immediately raised, and you'll
need error trapping code to handle this error.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Fred Smith" wrote in message
...
What's the difference between

Application.WorksheetFunction.Vlookup and
Application.Vlookup?

As far as I can tell they both work. However, one difference

I've found is
that when the Vlookup fails,

Application.WorksheetFunction.Vlookup returns
nothing, but Application.Vlookup returns N/A.

Is there any need to use WorksheetFunction? It would save a lot

of typing if
I didn't have to use it.

--
Regards,
Fred
Please reply to newsgroup, not e-mail