View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_5_] Dave Peterson[_5_] is offline
external usenet poster
 
Posts: 1,758
Default Problem w/ Match prop vs. Match method

Try dropping the .worksheetfunction from your code:

with application
junk = .VLookup("Min", table, .Match("Gorge", top, 0))
end with

if iserror(Junk) then
msgbox "Hey, there wasn't a match"
else
msgbox junk
end if

=========
If you want to keep the .worksheetfunction, you'll have to see if there was a
runtime error.

with application.worksheetfunction
on error resume next
junk = .VLookup("Min", table, .Match("Gorge", top, 0))
if err.number < 0 then
msgbox "Hey, there wasn't a match"
err.clear
else
msgbox junk
end if
on error go to 0
end with

===
By using the with/end with stuff, I could save some typing.

George Raft wrote:

Wishing all a happy new year ...

I get a runtime error with this piece of code:

junk = Application.WorksheetFunction.VLookup("Min", table,
Application.WorksheetFunction.Match("Gorge", top, 0))

junk is variant, table and top are ranges.

The error is:

"Unable to get the Match Property of the WS function"

If I replace the ref to App.WSF.Match with an integer, it works fine.

Thoughts?

Thanks, Tony


--

Dave Peterson