Formula needed to perform a rollup calculation

Celly

Board Regular
Joined
Jan 29, 2015
Messages
84
Office Version
  1. 2016
Platform
  1. Windows
I'm looking to roll up a calculation on a single dimensional range into a single cell formula. This is typically easily solvable by using a sequence of cells, however my requirement is a single cell solution which works on an arbitrary range.

So if the range is A1:A5, the formula is: (A1) + (A1 * A2) + (A1 * A2 * A3) + (A1 * A2 * A3 * A4) + (A1 * A2 * A3 * A4 * A5)

Is this possible? Sumproduct doesn't seem up to the task.
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
If you're fine with a VBA solution, try:

VBA Code:
Sub me1159242_formula()
    Dim i As Long, j As Long, s As String
    s = "=("
    For i = 1 To Cells(Rows.Count, 1).End(xlUp).Row 'A1 to last row of A
        For j = 1 To i
            If i > 1 Then
                s = s & Cells(j, 1).Address(0, 0) & "*"
                If j = i Then s = Left(s, Len(s) - 1) & ")+"
            Else
                s = s & Cells(j, 1).Address(0, 0) & ")+"
            End If
        Next
        s = s & "("
    Next
    ActiveCell.Formula = Left(s, Len(s) - 2)
End Sub

This puts a formula according to what you wanted into the currently selected cell. Range used is A1 to last row of A.
 
Upvote 0
See if the following single-cell formula works for you:
Excel Formula:
=SUMPRODUCT(SUBTOTAL(6,OFFSET(A1,,,ROW(A1:A5)-ROW(A1)+1)))
 
Upvote 0
Solution
See if the following single-cell formula works for you:
Excel Formula:
=SUMPRODUCT(SUBTOTAL(6,OFFSET(A1,,,ROW(A1:A5)-ROW(A1)+1)))

OK I had to study that one for a while. It looks like the brilliant part is passing a range to the OFFSET height parameter to return a jagged array.

So this variation is equivalent:

{=SUM(SUBTOTAL(6,OFFSET(A11,,,ROW(A11:A15)-ROW(A11)+1)))}

That's a nice technique, thanks Tetra!
 
Upvote 0

Forum statistics

Threads
1,215,043
Messages
6,122,816
Members
449,095
Latest member
m_smith_solihull

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