Search code examples
if-statementgoogle-sheetsspreadsheetequalitycountif

How to get Google Sheets to reliably compare text cells that include "<" and ">"?


As you can see in this sample scenario, I am having trouble reliably comparing cells A and B. It seems to have something to do with the "<" and ">" signs.

In my actual use case, I let conditional formatting highlight repeated values in a column using a formula similar to the one in cell C1 =countif($A2:$A,$A2)>1. However, that formula becomes totally unreliable when cells contain the "<" and ">" signs. This is a problem because I want to compare text cells that often contain HTML.

What’s the matter and is there a workaround?

enter image description here

I also recreated the image above using a table:

A B =if(countif($A2:$B2,$A2)>1,"Yes","No")
whatever> <whatever No
<> whatever Yes
whatever <> No
<><> <> No
<>whatever <whatever> Yes
<>whatever <>whatever Yes
whatever<> <whatever> No
whatever<> <>whatever No
><>< No
><>< <whatever> Yes
<><> Yes
<><> <whatever> Yes
<>< >< Yes
<>< <> Yes
><> >< Yes
><> <> No
<> ><> Yes
< > No
> < No
<> >< Yes
>< <> Yes
<< >> No
>> << No
<< <> No

Solution

  • to compare A1 to B1 formula is:

    =ARRAYFORMULA(IF(A1:A24=B1:B24, "Yes", "No"))
    

    enter image description here