View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Using Excel functions in VBA

You don't have to use worksheetfunction as the prefix for any
worksheetfunction that is supported for being called from VBA. You may also
use Application instead in just about every case that I can think of.

--
Regards,
Tom Ogilvy

"Naz" wrote in message
...
You are correct that Worksheetfunction doesn't work with this particular
one
(whoops)...but what does

" Even the OP demonstrated that you don't. "

what does that mean?



--

_______________________
Naz,
London


"Tom Ogilvy" wrote:

That is incorrect. Even the OP demonstrated that you don't.

--
Regards,
Tom Ogilvy

"Naz" wrote in message
...
You have to use the worksheetfunction. prefix instead of application


HTH

_______________________
Naz,
London


"alistre" wrote:

I wrote the following code in VBA. This worked fine.

Range("C30").Value = Application.Index(Range("A1:I18"), "13",
"6")

I compared this code to the one below which is similar in format. Am
I
correct in assuming in order to codify an Excel function in VBA all
you
have to do is Add the prefix "Application." to the function name
followed by parenthesis and the internal variables? I assumed this
when writing the following code that yielded an error. When I ran the
code a dialog popped up stating "Object doesn't support this Property
or Method".

Range("C27").Value = Application.Address(Range("C26").Value,
"4",
"4")

Perhaps the function "Address" was not recognized in VBA.

Although the "Application." prefix worked in the first line of code, I
thought one had to write "Application.WorksheetFunction." preceding
the
actual excel function in order to codify the function. Would someone
please clarify?