Counting consecutive non zero numbers in a column

Nikeyg

New Member
Joined
Jan 22, 2018
Messages
15
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.

1641221222375.png


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

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
How about this?

Book3
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAF
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)
 
Upvote 0
Solution
Upvote 0

Forum statistics

Threads
1,214,527
Messages
6,120,058
Members
448,940
Latest member
mdusw

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