Search code examples
google-sheetssplitgoogle-sheets-formulaconditional-formatting

Conditional Formatting with split string and wildcard


I have a database from A4:AV for different strings.

DATA SET
|Data|
|12AB34 Toyota|
|12CD34 Ford|
|12AB56 Hyundai|
|78CD90 Kia|
|78EF90 Benz|

I would like to write a conditional formatting code that highlights if 1st/2nd/5th/6th character happen more than once.

For example if in A4 there is "12AB34 Toyota", and in A5 "12CD34 Ford" they would both highlight as both A4 and A5 have XX??YY twice (12--34). The same for "78CD90 Kia" and "78EF90 Benz" as they both have XX??YY twice (78--90).

I've tried using this formula for column A4:A first: =SUMPRODUCT((LEN(A4:A)>5)*((MID(A4:A,1,1)&MID(A4:A,2,1)&MID(A4:A,5,1)&MID(A4:A,6,1))=REGEXREPLACE(A4:A,"(.)\\1{1}","$1")))>0

But I cannot get it to work, if you can help that would be a massive help!

Here is a sheet of desired outcomes link


Solution

  • You may try this custom formula in CF

    =(len(A4)>5)*(index(countifs(mid($A$4:$Z,1,2),mid(A4,1,2),mid($A$4:$Z,5,2),mid(A4,5,2)))>1)
    

    enter image description here