Forum Discussion
jpsaini91
Apr 27, 2022Copper Contributor
Needs a formula to return true if a cell contains three or more consecutive letters
<p> For ex: 98ABCD8 returns true 98XYZ99 returns true 88DG987 returns false Help me here, please. Needs a formula rather than a VBA code. Thank you </p>
- Apr 27, 2022
That formula won't work in Office 2013.
Try this. It is an array formula that has to be confirmed with Ctrl+Shift+Enter.
With a value such as 12ABS34 in A2:
=MAX(FREQUENCY(IF(ISERROR(-MID(A2,ROW(INDIRECT("1:"&LEN(A2))),1)),ROW(INDIRECT("1:"&LEN(A2)))),IF(ISNUMBER(-MID(A2,ROW(INDIRECT("1:"&LEN(A2))),1)),ROW(INDIRECT("1:"&LEN(A2))))))>=3
The formula can be filled down if required.
jpsaini91
Apr 27, 2022Copper Contributor
I am using office 2013. And this formula returned pop-up error.
HansVogelaar
Apr 27, 2022MVP
That formula won't work in Office 2013.
Try this. It is an array formula that has to be confirmed with Ctrl+Shift+Enter.
With a value such as 12ABS34 in A2:
=MAX(FREQUENCY(IF(ISERROR(-MID(A2,ROW(INDIRECT("1:"&LEN(A2))),1)),ROW(INDIRECT("1:"&LEN(A2)))),IF(ISNUMBER(-MID(A2,ROW(INDIRECT("1:"&LEN(A2))),1)),ROW(INDIRECT("1:"&LEN(A2))))))>=3
The formula can be filled down if required.
- jpsaini91Apr 27, 2022Copper ContributorFirst, thanks a ton, that formula works, exactly what I needed.
Second, I am just a layman, knows basic and doesn't even begin to understand how that formula of yours work.
Thanks again.- MindreVetandeApr 27, 2022Iron Contributora loooong formula but perhaps easier to understand?
=ISNUMBER(SEARCH("xxx",(IFERROR(MID(A2,1,1)*1,"x")&IFERROR(MID(A2,2,1)*1,"x")&IFERROR(MID(A2,3,1)*1,"x")&IFERROR(MID(A2,4,1)*1,"x")&IFERROR(MID(A2,5,1)*1,"x")&IFERROR(MID(A2,6,1)*1,"x")&IFERROR(MID(A2,7,1)*1,"x"))))
Replace everything that's not a number with the letter x,. Example first char :
IFERROR(MID(A2,1,1)*1,"x") (take char 1 and multiplicate with 1. If its a letter you get an error and put leter X)
etc, for 7 positions, join with "&" and then search for xxx. If xxx exist you get a number an ISNUMBER gets true
ISNUMBER(SEARCH("xxx",.... - HansVogelaarApr 27, 2022MVP
It's based on How to count max number of consecutive positive / negative numbers in Excel?
But with a different condition.