There are some worksheet functions where it doesn't really matter (maybe speed
is slightly affected???) if you use:
Application.somefunction()
or
application.worksheetfunction.somefunction()
or
worksheetfunction.somefunction()
But one of the nice things is that if you use worksheetfunction (with or without
the application object), you'll get a hint of what comes next with the VBE's
intellisense and autocomplete.
If you type:
application.worksheetfunction.
(with the dot)
you'll see all the worksheet functions that you can use (autocomplete)
If you type:
application.worksheetfunction.vlookup(
you'll see (not too informative) 4 arguments (arg1, arg2, arg3, arg4)
You won't see that if you use application.vlookup.
But (you didn't ask about this), there is a difference with a few functions on
how errors are treated between:
Application.vlookup() (and application.match())
and
application.vlookup() (and application.worksheetfunction.match())
If you don't use the .worksheetfunction portion, then you can test the returned
results for an error:
Dim res as variant 'could be an error
res = application.vlookup("someval", somerangehere, 2, false)
if iserror(res) then
msgbox "no match"
else
msgbox res
end if
===========
But when you use worksheetfunction.vlookup(), then you'll have to program
against a run time error.
dim res as long 'or string or even variant
on error resume next
res = application.vlookup("someval", somerangehere, 2, false)
if err.number <> 0 then
err.clear
msgbox "no match"
else
msgbox res
end if
on error goto 0
============
Personally, I like using the
if iserror(res) then
version
And I hardly ever (almost never??) use worksheetfunction.
If you continue to hang out in the excel newsgroups, I bet you'll find that the
people who use application.vlookup() are the ones who have been using excel
longer (application.worksheetfunction.vlookup() was added in xl97 (IIRC))--or
they've picked up this nasty <vbg> habit from the longer time users.