How to identify per row sequence of 5 cells containing number "8"

M209

New Member
Joined
Jul 21, 2011
Messages
4
Hello -
I need to identify and count , on a row by row basis, each occurrence of a sequence of five cells that each contain the number "8" . I am looking for the results to be something like: Row 1 = 2, Row 2 = 3, Row 3 = 1, Row 4 = 2 etc... with the "= n" being the number of times in that row that there exists a sequence of five cells that contain the number "8". Seems like it should be simple(?) but so far I can not find a solution. Thank you!
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Hello -
I need to identify and count , on a row by row basis, each occurrence of a sequence of five cells that each contain the number "8" . I am looking for the results to be something like: Row 1 = 2, Row 2 = 3, Row 3 = 1, Row 4 = 2 etc... with the "= n" being the number of times in that row that there exists a sequence of five cells that contain the number "8". Seems like it should be simple(?) but so far I can not find a solution. Thank you!
Try this array formula**:

=SUM(IF(FREQUENCY(IF(A1:R1=8,COLUMN(A1:R1)),IF(A1:R1<>8,COLUMN(A1:R1)))=5,1))

** array formulas need to be entered using the key
combination of CTRL,SHIFT,ENTER (not just ENTER).
Hold down both the CTRL key and the SHIFT key
then hit ENTER.

Copy down as needed. Adjust the ranges to suit.
 
Upvote 0
How about a "bonus question"...? :laugh:

The wonderful array formula you provided will count sequences of exactly five cells - no more, no less - that contain the number "8". Is there a way to change the formula so it counts sequences of 5 or more cells? For example, if there is a sequence of 10 cells in a row and each cell contains the number "8", can we modify the formula to count this as well?
 
Upvote 0
How about a "bonus question"...? :laugh:

The wonderful array formula you provided will count sequences of exactly five cells - no more, no less - that contain the number "8". Is there a way to change the formula so it counts sequences of 5 or more cells? For example, if there is a sequence of 10 cells in a row and each cell contains the number "8", can we modify the formula to count this as well?
Just change =5 to >=5.

=SUM(IF(FREQUENCY(IF(A1:R1=8,COLUMN(A1:R1)),IF(A1:R1<>8,COLUMN(A1:R1)))>=5,1))

Don't forget...array enter!
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,289
Members
452,902
Latest member
Knuddeluff

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