SUM Range Between Zeros
Exceller wrote...
Thank you, Ron. It works, but if I mix the references and extend the formula
down the range, subsequent zeros entered make the references below it return
errors. For example, when I changed the references and dragged it down the
column to extended the range, and then added zeroes within the range
(overwriting the formula) all the formulas below it returned an error
Formula with changed references, dragged down to row 20
=SUM(INDEX($A$2:$A200,
MAX(INDEX(($A$2:$A200=0)*ROW($A$2:$A200),0))):$A2 00)
....
Ron's formula has a bug in it. First off,
MAX(ISNUMBER(A2:A5)*(A2:A5=0)*ROW(A2:A5))
returns 2, 3, 4 or 5, but the row indices for A2:A5 are 1, 2, 3 and 4.
An off-by-one bug. If the last zero is in the last row, the MAX term
returns one more than the number of rows in the range, and that leads
to a #REF! error.
So, I need the formula to dynamically sum the values between the zeros
within the entire range (A2: A200); or really, I need it to sum the values
above it 0, until it reaches the first 0 above it.
....
If the formula should return zero if the value immediately above it
were zero, try
=SUMPRODUCT(--(ROW(rng)LOOKUP(2,1/(rng=0),ROW(rng))),rng)
and if the range could contain blank cells, try
=SUMPRODUCT(--(ROW(rng)LOOKUP(2,1/ISNUMBER(rng)/
(rng=0),ROW(rng))),rng)
|