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

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Nikeyg

New Member
Joined
Jan 22, 2018
Messages
15
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,331
Messages
5,836,683
Members
430,444
Latest member
WrenchBoy

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
Top