Counting consecutive non zero numbers in a column

Nikeyg

New Member
I'm trying to put together a spreadsheet to count staf absences for a school.
I this I have the date numbers across the top, I have two rows that will be filled with staff absences for those dates. I need to have a row at the top of the data underneath the dates which is to count the consecutive cells where the number is not 0.
So, if there are 5 consecutive cells that are not zero the count will be 5. However, if the next cell is 0 the count will reset to 0 and then start again when we have a new non zero cell.

In the above image for instance the count on the 10th would say '9', and then when it starts again on the 15th it would say '1' and end with '4' on the 18th.
Any idea how I can achieve this with a formula?

Realistically in the above scenario, while I require the two separate absence lines I will actually need the count to refer to both rows, instead of just row 3. So, each day would be row 3+row 4.

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Book3
2Teacher Consec0123456789000012340001230012345
3Both Consec01234567891011121314151617001234567891011
4
5
6Teacher Abs0112211145000011210001230041211
7Support Abs0100031201112311000011221133122
Sheet1
Cell Formulas
RangeFormula
B2B2=(B6>0)+0
C2:AF2C2=IF(C6>0,B2+1,0)
B3B3=(SUM(B6:B7)>0)+0
C3:AF3C3=IF(SUM(C6:C7)>0,B3+1,0)

Replies
2
Views
69
Replies
6
Views
301
Replies
37
Views
1K
Replies
3
Views
133
Replies
8
Views
190

1,217,498
Messages
6,136,998
Members
450,037
Latest member
Tao86

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.

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

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