Posted on October 20, 2011
1
2
3
4
5
6
7
8
9
| 'Arrays, Collections, Lists - How to sum all the elements in an array
' A polymorphic function that sums the values in any array
Function ArraySum(arr As Variant) As Variant
Dim I As Long, result As Variant
For I = LBound(arr) To UBound(arr)
result = result + arr(I)
Next
ArraySum = result
End Function |