Counting MAX number of consecutive blank cells

voitoosh

New Member
Joined
May 19, 2013
Messages
32
Hi All,
I have an Excel 2010-related problem.
I need some tips on how to solve this. I have tried some formulas but it only puzzled me :/

I have a row of data, e.g.

WORK WORK WORK WORK __ __ __ __ __ OFF OFF OFF OFF __ __ __ LVE LVE __ WORK WORK WORK. -> this should return 5, as it is the biggest "block" of consecutive blank cells.

I need to calculate what is the MAX number of blank cells in this row (I have tried countifs, MAX etc) but there is probably one long formula to do so. Also, these (blanks) appear in a different places throughout the row (it is basically a roster of a person).

Any ideas how to tackle this without VBA (in which I am rubbish)?

Help much appreciated!

Thanks a lot!
 
Basically row 4 would be 'scanned' from E to O and the result would be 1 because there is only 1 consecutive blank...

Whereas row 7 would be scanned from F to O and the result would be 2 because there are 2 consecutive blanks....

Based on the row attribute being X or Y (to be added later) if the consecutive blanks are greater than 1 (for X) or 3 (for Y) then that row has been an unbroken pattern within the timeline it has been active....if that makes sense...

In reality the first column can always be E...now I think about it...so the last active row is the only thing that needs to be dynamically driven.

Column
E
FGH
IJKLMNO
Row
Jan-12Feb-12Mar-12Apr-12
May-12Jun-12Jul-12Aug-12Sep-12Oct-12Nov-12
4
322720
29713068127
5
911261170144143771061618
6
128102568
9355293014473129
7
834411
60
55
5568132
8
1613510197
932712099
9
14596131143
6391137137826
10541072513312849216469
11861013680717812965118
121142132146134126392265

<colgroup><col><col span="11"></colgroup><tbody>
</tbody>



<colgroup><col><col><col><col><col><col><col><col><col><col><col><col><col><col></colgroup><tbody>
</tbody>
 
Upvote 0

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Basically row 4 would be 'scanned' from E to O and the result would be 1 because there is only 1 consecutive blank...

Whereas row 7 would be scanned from F to O and the result would be 2 because there are 2 consecutive blanks....

Based on the row attribute being X or Y (to be added later) if the consecutive blanks are greater than 1 (for X) or 3 (for Y) then that row has been an unbroken pattern within the timeline it has been active....if that makes sense...

In reality the first column can always be E...now I think about it...so the last active row is the only thing that needs to be dynamically driven.

ColumnEFGHIJKLMNO
RowJan-12Feb-12Mar-12Apr-12May-12Jun-12Jul-12Aug-12Sep-12Oct-12Nov-12
432272029713068127
5911261170144143771061618
61281025689355293014473129
783441160555568132
81613510197932712099
9145961311436391137137826
10541072513312849216469
11861013680717812965118
121142132146134126392265

<tbody>
</tbody>



<tbody>
</tbody>

E fixed, End dynamic.

Define BigNum as referring to:

=9.99999999999999E+307

Control+shift+enter, not just enter, and copy down:
Rich (BB code):
=MAX(FREQUENCY(IF(E2:INDEX(E2:Z2,MATCH(BigNum,E2:Z2))="",
     COLUMN(E2:INDEX(E2:Z2,MATCH(BigNum,E2:Z2))),
     IF(E2:INDEX(E2:Z2,MATCH(BigNum,E2:Z2))<>"",
     COLUMN(E2:INDEX(E2:Z2,MATCH(BigNum,E2:Z2))))))
 
Upvote 0
Perfect expect for one issue....if E2 is the only cell with a value, so the combination has only become active this last month...it evaluates to #Value, presumably it's the FREQUENCY Statement rather than the INDEX or COLUMN statments....?
 
Upvote 0
Perfect expect for one issue....if E2 is the only cell with a value, so the combination has only become active this last month...it evaluates to #Value, presumably it's the FREQUENCY Statement rather than the INDEX or COLUMN statments....?

Let's wrap the formula into an IFERROR call...
Rich (BB code):
=IFERROR(MAX(FREQUENCY(IF(E2:INDEX(E2:Z2,MATCH(BigNum,E2:Z2))="",
   COLUMN(E2:INDEX(E2:Z2,MATCH(BigNum,E2:Z2)))),
   IF(E2:INDEX(E2:Z2,MATCH(BigNum,E2:Z2))<>"",
   COLUMN(E2:INDEX(E2:Z2,MATCH(BigNum,E2:Z2)))))),0)
Change the 0 in IFERROR to "" if that's more appropriate.
 
Upvote 0
Hi ya, superb.....and.....sorry....

What about if I want to count blanks and zeros the same.....would I need to duplicate the FREQUENCY statment or merely double the parameters in the array selection?

I know it's a nightmare when people keep expanding requirements.....
 
Upvote 0
Hi ya, superb.....and.....sorry....

What about if I want to count blanks and zeros the same.....would I need to duplicate the FREQUENCY statment or merely double the parameters in the array selection?

Control+shift+enter and copy down:
Rich (BB code):
=IFERROR(MAX(FREQUENCY(IF(1-ISNUMBER(1/E2:INDEX(E2:Z2,MATCH(BigNum,E2:Z2))),
   COLUMN(E2:INDEX(E2:Z2,MATCH(BigNum,E2:Z2)))),
   IF(ISNUMBER(1/E2:INDEX(E2:Z2,MATCH(BigNum,E2:Z2))),
   COLUMN(E2:INDEX(E2:Z2,MATCH(BigNum,E2:Z2)))))),0)

I know it's a nightmare when people keep expanding requirements.....

:ROFLMAO:... Quite true;)
 
Upvote 0
Hi there, sorry I'm using this formula...didn't use the dynamic range expansion in the end.

=MAX(FREQUENCY(IF(OFFSET(J3,0,0,1,COUNTA($J$2:$AI$2))="",COLUMN(OFFSET(J3,0,0,1,COUNTA($J$2:$AI$2)))),IF(OFFSET(J3,0,0,1,COUNTA($J$2:$AI$2))<>"",COLUMN(OFFSET(J3,0,0,1,COUNTA($J$2:$AI$2))))))

So it needs to count the MAX number of consecutive blanks and/or zeros, currently it's just counting blanks and zeros are not counted...unfortunately the data I'm using is 'flexible' so sometimes it can display 0 and sometimes "" even though they essentially represent the same NULL value....
 
Upvote 0
Hi there, sorry I'm using this formula...didn't use the dynamic range expansion in the end.

=MAX(FREQUENCY(IF(OFFSET(J3,0,0,1,COUNTA($J$2:$AI$2))="",COLUMN(OFFSET(J3,0,0,1,COUNTA($J$2:$AI$2)))),IF(OFFSET(J3,0,0,1,COUNTA($J$2:$AI$2))<>"",COLUMN(OFFSET(J3,0,0,1,COUNTA($J$2:$AI$2))))))

So it needs to count the MAX number of consecutive blanks and/or zeros, currently it's just counting blanks and zeros are not counted...unfortunately the data I'm using is 'flexible' so sometimes it can display 0 and sometimes "" even though they essentially represent the same NULL value....

OFFSET/COUNTA has the same intent as the one I provided. What is the reason for dismissing the formula already crafted for you?
 
Upvote 0
Hiii,

I am facing same type of challenge where i have to count maximum no of consecutive filled cells(Instead of blank).

Please help
Thanks
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,752
Members
448,989
Latest member
mariah3

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