Count Consecutive Cells Containing specific text?

slam

Well-known Member
Joined
Sep 16, 2002
Messages
921
Office Version
  1. 365
  2. 2019
Let's say in F2 to X2, I sometimes have the text DNS. In AN2, How can I count the consecutive instances of DNS?

Thanks
 
Last edited:
the row() component is a function (confusing, I guess, given my use of 'range' as well):

=max(frequency(if(F2:X2="DNS",row(F2:X2)),if(F2:X2<>"DNS",row(F2:X2))))

ah, my mistake. Entered as an array formula, but still just giving me the total instances rather than the highest consecutive streak.
 
Last edited:
Upvote 0

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
forgot you were going across not down:

=max(frequency(if(F2:X2="DNS",column(F2:X2)),if(F2:X2<>"DNS",column(F2:X2))))
 
Upvote 0
One more question if I may.....

How would I combined that with the formula below to count consecutive instances that don't equal DNS or -

=SUMPRODUCT(((F2:X2<>"DNS")*(F2:X2<>"-")))
 
Upvote 0
Example below.

The yellow text indicates the longest consecutive streak that doesn't include DNS or -, and the total is indicated in red text. The red text is what I need to automate.


cryt.jpg
 
Upvote 0
Hhhmmm...

That's feels like it's going to bit a bit harder (i.e. not just a simple or() check for either string).

Not going to have much time over next week or so, so I'll see if I can solicit some help...
 
Upvote 0
I'm also trying to make this work for consecutive values >/= 15. Some help on that would also be greatly appreciated!

Thanks
 
Upvote 0

Hhhmmm...

That's feels like it's going to bit a bit harder (i.e. not just a simple or() check for either string).

Not going to have much time over next week or so, so I'll see if I can solicit some help...

Y2, control+shift+enter and copy down:
Rich (BB code):
=MAX(FREQUENCY(IF(1-((F2:X2="DNS")+(F2:X2="-")),COLUMN(F2:X2)),
    IF((F2:X2="DNS")+(F2:X2="-"),COLUMN(F2:X2))))

Assumed that there will be no empty/blank cells.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,226,488
Messages
6,191,318
Members
453,653
Latest member
mvillasana

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