sum elements in an Array

Andre314

New Member
Joined
Dec 14, 2013
Messages
2
hello,

What's wrong in my function?
I get #Value.

Regards,
Andre

Function total(zeros As Variant) As Double
Dim sum As Double
Dim i As Integer
sum = 0#
For i = 1 To UBound(zeros)
sum = sum + zeros(i)
Next i
total = sum
End Function
 
Hi

Without knowing what your zeros variable is we cannot test.

Please post the declaration and initialisation of the variable zeros and also the statement where you use the total function.
 
Upvote 0
Hi

Without knowing what your zeros variable is we cannot test.

Please post the declaration and initialisation of the variable zeros and also the statement where you use the total function.

Sorry, I am new to this forum.
But I want to use this functions as follows:
cell c1 has value 1
cell c2 has value 2
....
cell c10 has value 10

in cell d1 I use the function =total(c1:c10)
This is an example, in reality is the function more complex.
I am using Excel 2003.
 
Last edited:
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top