Calculating a Series

D

deluth

Please help me put together a function to calculate a sum series as follows:
For n = 0 to n=(B3-B1): sum ((A1 + (A3*n)) * A6)

Thank you,
Deluth
 
J

Joe User

deluth said:
Please help me put together a function to calculate
a sum series as follows:
For n = 0 to n=(B3-B1): sum ((A1 + (A3*n)) * A6)

Well, you could write the following UDF. Note that the variable names a1,
a3, etc do not have to match the cell names. I use them just to help you
relate to the above formula. You can call the UDF from Excel with any cells;
for example: =mysum(A1,A3,A6,B1,B3)

However, note that the series sum can be reduced to a single algebraic
formula. So instead of the UDF, you can write:

=A6* (A1*(B3-B1+1) + A3*(B3-B1)*(B3-B1+1)/2)

which can be simplified further to:

=A6 * (B3-B1+1) * (A1+A3*(B3-B1)/2)

UDF....

Option Explicit
Function mysum(a1 As Double, a3 As Double, _
a6 As Double, b1 As Double, b3 As Double) _
As Double
Dim s As Double, n As Double
s = 0
For n = 0 To b3 - b1
s = s + (a1 + (a3 * n)) * a6
Next
mysum = s
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Calculating Sum Series 1
Formula fill series? 1
Looking to added up based on a character from cell range 1
To Sum Up 2
To Sum Up 1
up and down array 7
Need to have data in one column 1
Getting "N/A" 2

Top