writing a Function with a variable number of arguments
Tony,
You need to use ParamArray. Here is a simple example
Function myTest(ParamArray vals())
Dim i As Long
Dim mysum
For i = LBound(vals, 1) To UBound(vals, 1)
mysum = mysum + vals(i)
Next i
myTest = mysum
End Function
--
HTH
Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
"TonyJeffs" wrote in message
m...
How do I write a function that can take any number of integers?
for example
function MyAverage(x as integer, [any amount more] as integers)
...
end function
Thanks
Tony
|