Checking if a sequence of values is met

Ride The Lightning

Board Regular
Joined
Jul 14, 2005
Messages
238
Hi

I have a column of data with the values either True or False. I want to set up a formula that calculates if "True" appears 5 times in a sequence. I have tried the IF function and tried using it in an array, however, the formula doesn't account for the whole range.

Any pointers of what I could use would be much appreciated.

Cheers

RTL
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Do you mean exactly 5 times in sequence, or at least 5 times?
 
Upvote 0
This should do the trick. Just change the range to whatever you need it to be.

Code:
=IF(COUNTIF(A1:A10, "=TRUE") = 5, TRUE, FALSE)
 
Upvote 0
If you did want the value to be true if it is more than 5 then just change it to:

Code:
=IF(COUNTIF(A1:A10, "=TRUE") > 5, TRUE, FALSE)
 
Upvote 0
COUNTIF will only tell you if TRUE appears 5 times somewhere in the list, not in sequence.
 
Upvote 0
Hi,

Assuming True and False are boolean values (not text) in range A1:A10 the array-formula below checks if exactly 5 consecutives True exist

=IF(MAX(FREQUENCY(IF(A1:A10,ROW(A1:A10)),IF(NOT(A1:A10),ROW(A1:A10))))=5,"Yes","No")

Ctrl+Shift+Enter

HTH

M.
 
Upvote 0
oops...

My formula has a flaw, if exists 6 consecutives True and also 5.

Wait, need to re-think

M.
 
Upvote 0

Forum statistics

Threads
1,224,570
Messages
6,179,610
Members
452,931
Latest member
The Monk

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