I'm not sure what you are really looking for, but perhaps the
following might get you started:
Function AddThemUp(ParamArray Args() As Variant) As Double
Dim N As Long
Dim L As Long
For N = LBound(Args) To UBound(Args)
If IsNumeric(Args(N)) = True Then
L = L + Args(N)
End If
Next N
AddThemUp = L
End Function
This function takes any number of input parameters and returns the sum
of those parameters. E.g,.,
Dim X As Long
X = AddThemUp(10,20,30)
Debug.Print X
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
On Mon, 7 Sep 2009 05:03:54 -0700 (PDT), "
wrote:
Can a function get repeated values, add them, and return a total to
the calling procedure?
I need to reuse this code with differing numbers of items.
Example
Pass these parameters
add_to(1)
add_to(2)
Get the returned total from function
function accum(number)
total = total + number
RETURN TOTAL to Procedure