Categories
Excel

Compare Two Strings in Excel: 3 Ways to Find Matching Text

Do you need to compare text in two cells to determine whether the strings are the same or different?

Excel provides several ways to do this. The method you choose will depend on whether the comparison should be case sensitive or not.

Here are 3 ways to compare strings in your Excel spreadsheet.

1) Compare Text Strings with the Equals Sign

The equals sign lets you compare two strings but it doesn’t differentiate between upper and lower case letters. In other words, it’s not case sensitive.

When two strings are the same, the formula will evaluate to TRUE. If the strings are different, the formula will evaluate to FALSE.

In the example (below), I entered =A2=B2 in cell C2. Excel indicates that the text in both cells are the same (TRUE) because the equals sign ignores capitalization.

Compare two cells with the equals sign

In cell C6, the formula =A6=B6 evaluates to false. “Oranges” and “Orange” are different.

2) Compare Text Strings with the EXACT Function

The EXACT function lets Excel compare two text strings in Excel and the results are case sensitive.

The EXACT function uses the following syntax:

=EXACT(text1, text2)

If the text strings are the same (including capitalization), the EXACT function will evaluate to TRUE. Otherwise, the EXACT function will evaluate to FALSE.

In the example (below), I typed =EXACT(A2,B2) into cell C2. Excel indicates that the text strings are different because the EXACT function is case sensitive.

Compare two cells with the EXACT function

3) Compare Text Strings with Conditional Formatting

You can utilize conditional formatting in Excel to compare strings and identify duplicate values but there are a couple of things you’ll want to keep in mind when using this method.

First, condition formatting isn’t case sensitive. It doesn’t differentiate between upper and lower case letters within text strings.

Second, as long as text strings appear more than once with the selected range, conditional formatting will count it as a duplicate – regardless of the word’s position within a column.

In the example (below), the word Apples appears in cell A2 and B5. Conditional formatting ignores capitalization and, since the word appears twice in the selected range, it formats those cells with a green background.

Use conditional formatting to compare text strings

How to Identify Duplicate Values with Conditional Formatting

Here are the steps I used to compare text strings and highlight duplicate values with conditional formatting.

  1. Drag to select A2:B6.
  2. Click the Conditional Formatting button in the Home > Styles group.
    Additional options appear.
  3. Point to Highlight Cells Rules then select Duplicate Values…
  4. Configure the Duplicate Values dialog box (as shown) then click OK.
Identify duplicate values with conditional formatting

Now You Can Compare Two Strings Like a Pro!

I hope you’ve enjoyed reading this article outlining how to compare strings in Excel. Each method accomplishes the task in a slightly different way.

By Michael Belfry

Working as a full-time training consultant, Michael provides Microsoft Office courses to government and private sector clients across Canada.