Home » excel » excel – Dynamic range that stops at the number before the last zero in a column

# excel – Dynamic range that stops at the number before the last zero in a column

Posted by: admin May 14, 2020 Leave a comment

Questions:

I have been trying to create a dynamic range within excel that would include all the rows in a column up until the last number before all the zeroes. For example here is the string of data.

0
0
350
500
107
0
200
500
27
736
0
0
0
0

In this case the numbers within the range that would be selected would be:

0
0
350
500
107
0
200
500
27
736

Any guidance would be greatly appreciated.

Thx

How to&Answers:

Assuming your data starts at `A1` on `Sheet1` you could define the range by using this formula in the “refers to” box

`=Sheet1!\$A\$1:INDEX(Sheet1!\$A:\$A,MATCH(2,1/(Sheet1!\$A:\$A>0)))`

that will include all the data up to the last >0 value

### Answer：

Assuming you have a header row and data starts in A2:

``````=INDEX(Sheet1!\$A:\$A,2):INDEX(Sheet1!\$A:\$A,(SUMPRODUCT(MAX((Sheet1!\$A:\$A<>0)*ROW(Sheet1!\$A:\$A)))))
``````