How to Compare Two Strings (Text) in Excel (Formula)

Last Updated: December 02, 2023
puneet-gogia-excel-champs

- Written by Puneet

In Excel, you can compare two strings with each other by comparing with two methods:

  • Case Sensitive
  • Non-Case Sensitive

In this tutorial, we will learn to write a formula for both methods.

Compare Two Strings with Non-Case Sensitive Match

  1. First, enter (=) sign in a cell.
  2. Refer to the cell with the first value.
  3. Again enter (=).
  4. Refer to the cell with the second value.
  5. In the end, hit enter to get the result.
compare-non-case-sensitive-match

You can see in the above example; in the first cell, you have “Excel,” and in the second cell, you have “EXCEL”. Both values are the same; the only difference is the case. And in the result, we have TRUE. As I said, this formula will not consider the case of the text while comparing.

=text1 = text2

Compare Two Strings with Case Sensitive Match

But if you want also to consider the case of the text while matching, you can use the EXACT function.

  1. Enter the EXACT function in a cell.
  2. Refer to the cell with the first value.
  3. Type a comma.
  4. Refer to the cell with the second value.
  5. Close the function and hit enter to get the result.
compare-case-sensitive-match

In the above example, we have the same values in all the cells, but you have TRUE, where the value is the same along with the case match.

Using IF to Compare Two Texts

You can also combine IF with both methods we have discussed above.

if-to-compare-two-texts
=IF(A1=B1,"Yes","No")
=IF(EXACT(A2,B2),"Yes","No")

Get the Excel File