Home > How-To Library > Arrays, Collections, Lists
How to sum all the elements in an array
**************************************************************** * © 2007 CodeItBetter http://www.codeitbetter.com * * This notice MUST stay intact for legal use * **************************************************************** ' 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
If you would like to submit your code here please us. Do not forget to mention your name. We are always thankful to each and everyone of you who submitted their code here.