View Single Post
  #13   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Harlan Grove[_2_] Harlan Grove[_2_] is offline
external usenet poster
 
Posts: 1,231
Default Array formula returning the cumulative sum

Bernd P wrote...
....
I tested them on 1000 rows with random integers between 1 and 999.

Calculation time in milliseconds (FastExcel) was:
Bernd 0.96
Ken 1.25
JMB 12.32
Lori 114.84
Harlan 534.70

The (optimal?) non array solution (B1: =A1, B2: A2+B1, copy down)
took 0.51


OK, now try each approach with a derived array rather than a range.

I won't (and didn't) claim my approach was fast, but it is flexible.

Note that your approach also relies on implicit indexing. You can
enter the array formula

=SUM($A$1:INDEX($A$1:$A$5,ROW($A$1:$A$5)))

[note: don't be overly broad with your range argument to ROW - with
your original argument, $1:$5, any change in rows 1 through 5 outside
column A would trigger recalculation of this array formula] in a 5-
cell range, but

=SUM(SUM($A$1:INDEX($A$1:$A$5,ROW($A$1:$A$5))))

would return the same thing as the previous formula, entered as an
array or not.