Counting rows between each specific value

colin5392

Board Regular
Joined
Oct 25, 2016
Messages
67
Office Version
  1. 2019
Platform
  1. Windows
I have a column of 1000+ numbers, but I want to be able to count the number of rows between each entry containing the value 1, e.g.

1 <--
15
25
3
5
2
1 <--
22
14
15
1 <--

How do I count those rows automatically please? Can anyone help?
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Not sure how efficient this will be based on how big you data set it but you could use this:


Book1
AB
11
215 
325
43
55
62
715
822
914
1015
1113
Sheet3
Cell Formulas
RangeFormula
B2=IF($A2=1,ROW()-LOOKUP(2,1/($A$1:$A1=1),ROW($A$1:$A1))-1,"")


WBD
 
Upvote 0
Not sure how efficient this will be based on how big you data set it but you could use this:

AB
11
215
325
43
55
62
715
822
914
1015
1113

<colgroup><col style="width: 25pxpx"><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet3

Worksheet Formulas
CellFormula
B2=IF($A2=1,ROW()-LOOKUP(2,1/($A$1:$A1=1),ROW($A$1:$A1))-1,"")

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>



WBD


Thanks, I'll give it a go
 
Upvote 0

Forum statistics

Threads
1,214,648
Messages
6,120,725
Members
448,987
Latest member
marion_davis

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