Thread: Lookup
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Lookup

Looks like one of use hosed it up - since you are missing a parentheses and
a quote.

It should be

dim res as variant
res =
application.lookup(LEFT(range("D5"),3), _
range("HTC!A2:A200"),range("HTC!b2:B200"))
if not iserror(res) then
msgbox res
else
msgbox "No match"
End if

the reason application is used is because it doesn't raise a vba error when
the match is not made and it works consistently, where at least in xl97,
some of the lookup and match functions would not work when using
Worksheetfunction. This may have been fixed in later verions.

But as Vasant said, if you want intellisense, then you have to use
worksheettfunction.

--
Regards,
Tom Ogilvy




"Dthmtlgod" wrote in message
...
Thank you Vasant


"Vasant Nanavati" <vasantn *AT* aol *DOT* com wrote in message
...
Type it in manually; it should work. Worksheet functions are now

accessed
through the WorksheetFunction object rather than the Application object,
although the latter still works for backward compatibility. Many experts
still prefer to use the Application object as it has some esoteric
advantages.

--

Vasant

"Dthmtlgod" wrote in message
...
I was given this piece of code by an MVP, and I think I am missing a
reference.

dim res as variant
res =



application.lookup(LEFT(range(D5"),3,range("HTC!A2 :A200"),range("HTC!b2:B200
"))

I don't get the lookup option after typing in application.

Please advise.