View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Schizoid Man[_2_] Schizoid Man[_2_] is offline
external usenet poster
 
Posts: 13
Default How do I declare a function whose output is an array?

Tom Ogilvy wrote:

so my comment about a variant required for passing to an array is pre-VBA6

However, you still need a variant to pick up a multicell contiguous range
from a worksheet in one go.


Hi Tom,

Thanks for the snippets. I'm using Excel Office XP, which I believe is
Excel 2002, so I'm using VBA6.

I still don't understand your second comment. For example, I replaced
all my Variant declarations with Double(), and though I haven't seen
significant improvements in speed, the function works perfectly.

One of my functions is declared as:
Public Function LossDist(defprob As Range, corrInput As Double,
numFactors As Integer) As Double()

Here the defprob range is a single-column range of 125 contiguous cells.
This functions works perfectly for me without having to resort to
declaring LossDist as a Variant, so I'm not sure what you mean.

Thanks.