View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Functions that return multiple calculated values

Tom,

This works okay for me

Function test()
Dim y As Variant
ReDim y(1)
If Day(Date) 20 Then
y(1) = 1
Else
y(1) = 0
End If
test = y
End Function

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Tom Kreutz" wrote in message
m...
I'm trying to write a function that will return multiple calculated
values. One way is to use the Array() function, which creates a
variant array, such as:

Function test()
Dim y As Variant
y = Array("a", "b")
test = y
End Function

However, I want to be able to output two CALCULATED values for y(1)
and y(2). If I try to do this in the code above, e.g. if ... then
y(1)=26, I get an error.

Am I missing somthing obvious?

Thanks in advance for any good ideas.

Tom Kreutz