count occurrences with reset

greg stan

New Member
Joined
Jul 30, 2023
Messages
2
Office Version
  1. 2019
Platform
  1. Windows
morning,

i have a column that contains '0's and '1's. I am trying to count the occurrences of '0's and reset the count after the first '1'. for every consecutive count of '1' after the first should show a 1. I have tried various ifs and count ifs formulas but I am struggling to get it working correctly. This is an example of what the column would look like and what the count would look like. id) 0,0,0,0,1,1,1,1,0,1,0,0,0,1,0 count) 1,2,3,4,5,1,1,1,1,2,1,2,3,4,1

many thanks in advance.
 

Attachments

  • count example.JPG
    count example.JPG
    21.2 KB · Views: 9

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Try this:

Book1
BC
1IDCount
201
302
403
504
615
711
811
911
1001
1112
1201
1302
1403
1514
1601
Sheet1
Cell Formulas
RangeFormula
C2:C16C2=IF(B1<>0,1,IF(B1=0,C1+1,1))
 
Upvote 0
Solution

Forum statistics

Threads
1,215,124
Messages
6,123,187
Members
449,090
Latest member
bes000

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