Arrays - Adding up numbers assigned to an array

  • Thread starter Thread starter owibach
  • Start date Start date
O

owibach

I'm sure this should be straight forward but I can't find the answer.
I've created an Array to hold 12 figures representing sales for 12 months.
How do I get a total for these without adding up the individual elements
such as Year(1) + Year(2) + Year(3) ...... There must be a function such as
DSUM applied to the array as a whole but I can't do it
 
Public Function SumArray(xArray())
Dim i As Long
Dim d As Double

For i = LBound(xArray) To UBound(xArray)
d = Nz(xArray(i), 0) + d
Next i

SumArray = d
End Function

--
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
Back
Top