How to group and count

gkintl

New Member
Joined
Oct 15, 2017
Messages
2
<article>
Hi, I would like to the formula to count if there is a "1" in the cell and stop if it encounters a "0". Again, it should start counting from 1, when it comes across a "1" in next cell.

It should look like this

A 1
B 1 2
C 0 0 <<Result
D 1 1
E 0 0
F 1
G 1
H 1 3
J 0 0

Can anyone help me with the formula? rgds,​
</article>
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
If Data starts From A2 and goes down, Formula in B2, then dragdown.

ARRAY formula is used
=IF($A2=0,0,IF($A3=0,IFERROR(ROWS($A$2:$A2)-MATCH(2,1/($A$2:$A2=0),1),ROWS($A$2:$A2)),""))

To enter ARRAY formula
Paste the formula
Press F2
Press Ctrl+Shift+Enter keys together.
formula will be covered with{} brackets by excel.
 
Upvote 0
In B2, copied down


Book1
AB
1NumbersCount
21 
312
400
511
600
71
81
913
1000
Count
Cell Formulas
RangeFormula
B2=IF(A2=0,0,IF(AND(A2=1,A3=0),SUM(A$1:A2)-SUM(B$1:B1),""))
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,975
Messages
6,175,749
Members
452,667
Latest member
vanessavalentino83

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