Here is a spreadsheet calculating the cells I would like the multistep way.

Solved

Posted on 2014-08-26

I would like to calculate the sum of a series of compounding products in a single cell. I can do this rather simply in excel by calculating the series of compounding products in a table, then summing each column of the resulting products. However, I would like to do this in a single cell, and without any VBA. Arrays would be fine.

The original data is organized as follows:

In a single row, there are multiple columns of fractions. After the 25th colum of data, the data changes from being displayed in a single row to being displayed down the 26th column. So the data is in a downward "L" shape in the table. Assume the data is in ROW 1 from COLUMN A to COLUMN Z, then continuing down COLUMN Z to ROW 30.

To do the calcualtion in multiple steps, I would calculate the compounding products as follows in a single row below the table:

First, remove the "L" shape in the table by copying the table to a new location, and transposing the data in the 26th column and appending it to the end of the ROW 1.

Then in cell A40 calculate, (1-A1), then in B40 calculate A40*(1-B1), and drag that formula accross the row to the end of the columns containing data.

Then in cell A45 calculate SUM(A40:[end of columns with data]). This is the final result I am looking for.

I woud like to calcualte all of this in a single cell and without having to "straighten out" the "L" shape in the original table.

The original data is organized as follows:

In a single row, there are multiple columns of fractions. After the 25th colum of data, the data changes from being displayed in a single row to being displayed down the 26th column. So the data is in a downward "L" shape in the table. Assume the data is in ROW 1 from COLUMN A to COLUMN Z, then continuing down COLUMN Z to ROW 30.

To do the calcualtion in multiple steps, I would calculate the compounding products as follows in a single row below the table:

First, remove the "L" shape in the table by copying the table to a new location, and transposing the data in the 26th column and appending it to the end of the ROW 1.

Then in cell A40 calculate, (1-A1), then in B40 calculate A40*(1-B1), and drag that formula accross the row to the end of the columns containing data.

Then in cell A45 calculate SUM(A40:[end of columns with data]). This is the final result I am looking for.

I woud like to calcualte all of this in a single cell and without having to "straighten out" the "L" shape in the original table.

8 Comments

Does your data resemble this layout?

I'm restating your request to understand:

1) The values in column Z (Z1:Z30) should be transposed to Z1:BC1

2) Cell A40:

3) Cell B40:

4) Cell A45:

Your goal is to derive the value shown in A45 without any of the transposition or intermediate formulas, correct?

-Glenn

Thanks for looking into this. I believe you have restated the request correctly.

I must have forgotten to click "upload file". I hope this post will upload it. The data in the attached is set up the same as I described, but has an entire table of the calculations to be performed that continue down each row instead of for just one.

Please let me know if you have any ideas on how to do this without all teh intermediate steps.

Thasnk,

John

Example-Table.xlsx

You could use an User Defined Function

```
Function fLifeExpectancy(rngData As Range) As Double
Set rwRange = rngData.Resize(1)
Set clRange = rngData.Offset(1, rngData.Columns.Count - 1).Resize(rngData.Rows.Count - 1, 1)
Set newRange = Union(clRange, rwRange)
Dim arrData()
ReDim arrData(newRange.Count - 1)
Idx = 0
For Each c In rwRange
If Idx = 0 Then
arrData(Idx) = 1 - c.Value / 1000
Else
arrData(Idx) = arrData(Idx - 1) * (1 - c.Value / 1000)
End If
Idx = Idx + 1
Next
For Each c In clRange
arrData(Idx) = arrData(Idx - 1) * (1 - c.Value / 1000)
Idx = Idx + 1
Next
fLifeExpectancy = WorksheetFunction.Sum(arrData)
End Function
```

RegardsExample-TableV1.xlsm

Frankly, I can't think of any other way to solve this. I think it's possible that an exponential array function can do this, but it would be the sum of two array functions (to handle the range transposition).

Glenn, Do you have a solution for calculating the data in a single cell if there is no kink in the table. A half-way there solution would be for me to straighten out the table, but not have to do all the interim calcs.

What is getting me is how to get the formula to create a series of compounding products that it can then sum. I can get the compounded number for any single column along the columns without calculating the prior columns by using an array formula such as:

{=PRODUCT(1-[DYNAMIC RANGE]/1000)}

Where [DYNAMIC RANGE] could be a cell range defined with $ signs or maybe using the OFFSET function.

But I can't get this to calculate all the prior compounded numbers in the prior columns and then sum them in that single cell.

The construction of the data in the first sheet makes it immensely difficult - if not impossible - to construct an array function to properly transpose into the compounding sum of products.

Regards,

-Glenn

Since you insist for a formula

pls try as Array Formula (Ctrl-Shft-Enter) in Cell B6

=SUM(PRODUCT(1-D6:D6/1000)

00,1-AC7:AC14/1000),0),IF(

0),IF(ROW(AC32)<102,PRODUC