count # of cells that are zero if more than 10 consecutive cell have zeros in them (XP, Excel 2010)

nearbeer

New Member
Joined
Feb 14, 2011
Messages
18
All,

Thank you for your time for looking at my question.

I would like to count the # of consecutive cells in a column that have a zero in them if there are more than 10 consecutive cells with a value of zero. For example, I have a spreadsheet that records production data from a machine. Each row represents one minute of the day (17:30, 17:31, 17:32, etc). If there are 10 or more consecutive rows that have zero (0) production recorded, I want to tally up those minutes. For one of my days of production, I have about 44 rows that had production one minute, zero the next, production for the next 12 mins, and then I went 19 mins without production due to a malfunction, and production picked back up after the 33rd minute; there were 3 minutes (non-consecutive) after that in which there was zero production. In this case, there would be 19 mins of downtime.

Let's say I have a range of minutes in Col. A (A1:A30) and in col. B I have a record of production units (1 or 2 units; never more than 2). From A9:A22 there was zero production; I want to have a value of 1 in G9 to indicate at that particular minute, the machine was down because the 10 min trigger had been reached if one were to look at the next 10 minutes. Since there are more than 10 cells with values of zero in A9:A22, I want G9:G22 to sum up to 14 minutes.

I tried nesting several if statements together but I couldn't get them to work.

I apologize for not posting an example spreadsheet; I am on my home computer while my spreadsheets are on my work computer.

I truly appreciate your time in helping me out.

Thank you,

Adam
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
I believe that if you paste this in row 10 and fill down for your whole range, it should get you pretty close to what you are looking for.

=IF(COUNTIF(A1:A10,0)=10,B9+1,0)

Let me know if it works or needs some tweaking.

Cheers, :)
 
Upvote 0
So the cells in column G will each have this same formula in it, or is the formula in just one cell?
 
Upvote 0
All,

Thank you for your time for looking at my question.

I would like to count the # of consecutive cells in a column that have a zero in them if there are more than 10 consecutive cells with a value of zero. For example, I have a spreadsheet that records production data from a machine. Each row represents one minute of the day (17:30, 17:31, 17:32, etc). If there are 10 or more consecutive rows that have zero (0) production recorded, I want to tally up those minutes. For one of my days of production, I have about 44 rows that had production one minute, zero the next, production for the next 12 mins, and then I went 19 mins without production due to a malfunction, and production picked back up after the 33rd minute; there were 3 minutes (non-consecutive) after that in which there was zero production. In this case, there would be 19 mins of downtime.

Let's say I have a range of minutes in Col. A (A1:A30) and in col. B I have a record of production units (1 or 2 units; never more than 2). From A9:A22 there was zero production; I want to have a value of 1 in G9 to indicate at that particular minute, the machine was down because the 10 min trigger had been reached if one were to look at the next 10 minutes. Since there are more than 10 cells with values of zero in A9:A22, I want G9:G22 to sum up to 14 minutes.

I tried nesting several if statements together but I couldn't get them to work.

I apologize for not posting an example spreadsheet; I am on my home computer while my spreadsheets are on my work computer.

I truly appreciate your time in helping me out.

Thank you,

Adam


Excel 2010
ABCD
117:301
217:3110
317:32
417:33
517:34
617:35
717:36
817:37
917:38
1017:39
1117:40
1217:41
130:00
140:00
150:00
160:00
170:00
180:00
190:00
200:00
210:00
220:00
230:00
2417:53
2517:54
2617:55
2717:56
2817:57
2917:58
3017:59
Sheet1
Cell Formulas
RangeFormula
D1{=SUM(--(FREQUENCY(IF(A1:A30>=0,ROW(A1:A30)),IF(A1:A30<>0,ROW(A1:A30)))>=D2))}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Cammy, if that's addressed to me, I was setting it up so as to copy it (or fill it) down for the whole range.

Cheers, :)
 
Upvote 0
Try this in VB

Sub test()
Dim timing As Range
Dim zeroprod As Integer
Dim downtime As Integer
Rownum = ActiveSheet.UsedRange.Rows.Count
Set timing = Range("B1:B" & Rownum)
zeroprod = 0
downtime = 0
Range("B1").Select
For i = 1 To timing.Cells.Count
If ActiveCell = 0 Then
zeroprod = zeroprod + 1
If zeroprod = 10 Then
downtime = downtime + 1
zeroprod = 0
Else
End If
Else: zeroprod = 0
End If
ActiveCell.Offset(1, 0).Select
Next i
If downtime >= 1 Then
Range("G2").Select
ActiveCell = downtime
Else
End If
End Sub


There may be a nicer way to write this, but this should work.

Assuming:

Times are in Colum A
In column B is looks for 10 0's in a row.
if there are 10's in a row (or More) it will return the number of times 0 is repeat 10 times into G2.

Hope that helps.
 
Upvote 0
All,

Many thanks for the responses so far; I will test them today and let you know the results.

Cammy84...my goal was to have the formula in each cell.

Again, thanks for everyone's help!!!
 
Upvote 0
Looking over my expression above, I believe that I have missed the point of the OP. Please alter my expression to the following (placed in row 10 and copied down)

=IF(COUNTIF(A1:A10,0)=10,if(b9=0,10,B9+1),0)

Cheers, :)

 
Upvote 0
All apologies for the delay in responding to everyone's help. Here is what a coworker came up with and it has worked for my needs:

I set my criteria for downtime to be any block of time that had zero production greater than 6 minutes.

To begin with, in column "L" I put the following:

=IF(AND([@ProductionCount]=0, C2=C3),1,"")

This told me whether or not in column "C" there was zero production for that minute ("C2") and the next minute ("C3"); returned a value of 1 if zero production.

Secondly, in column "M":

=IF(OR(L2="",L2<>L1),0,L2+M1).

This started counting the # of consecutive cells with zeros.

Finally, in column "N":

=IF(M2=6,7,IF(M2>=6,1,""))

This returned a value of 7 if a cell in col. "M" was 6 or a value of 1 if a cell in col. "M" was greater than 6. I had the cell return 7 because I wanted downtimes that were greater than 6 mins.

Many thanks for all that helped; it started me in the right direction.

/R,

Adam
 
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,391
Members
448,957
Latest member
Hat4Life

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