declare multiple variables
It looks like you are doing a UDF which by default can only return one value.
How about something more like this...
Function zum(byval Target as range) As double
dim w as worksheet
Application.Volatile
zum = 0
For Each w In Worksheets
zum = zum + w.Range(Target.Address).Value
Next w
End Function
Use it like
=Zum(C2)
or
=Zum(D2)
--
HTH...
Jim Thomlinson
"geebee" wrote:
hi,
is there any way i can declare multiple variables at the same time without
creating tons of different functions. for example, lets say i have:
Function zum() As Variant
Application.Volatile
zum = 0
For Each w In Worksheets
zum = zum + w.Range("C2").Value
Next
End Function
i want to be able to modify it to something like:
Function zum() As Variant
Application.Volatile
zum = 0
For Each w In Worksheets
zum = zum + w.Range("C2").Value
zum2 = zum2 + w.Range("D2").Value
zum3 = zum3 + w.Range("F2").Value
Next
End Function
how should I modify it?
thanks in advance,
geebee
|