How do I declare a function whose output is an array?
You can only pass an array to a variant variable (or in xl2000 and
later/vba6) to a variant array. so there is not clean up necessary for your
first question.
the values in a range can be treated as an array in almost all cases. As to
properties, an array does not have any properties so you can not use
rows.count and so forth except if you go against the original range and just
use the results against an array.
You can certainly loop through an array and manipulate the values much
faster than you can loop through the source range.
So I wouldn't say there is a simple yes no answer to whether to use a range
or an array. I think it depends on what you are doing.
--
Regards,
Tom Ogilvy
"Schizoid Man" wrote:
My current workaround to this problem is to declare the function as
Public Function xyz(abc as Range) as Variant
'Code
'klm is an array
xyz = klm
End Function
This works efficiently enough, but I would like to tidy up my code by
eliminating all non-explicit declarations.
Furthermore, can someone tell me what exactly the difference between an
array and a range is? For example, if I declare the function as
Public Function(abc() as Double) as Variant, how will that make a
difference? Is there any advantage of one over the other?
Will functions like Rows.Count or Application.Count work with an array?
Thank you in advance.
|