How to Compare Two Cells in Excel (Formula)

Last Updated: March 24, 2024
puneet-gogia-excel-champs

- Written by Puneet

To compare two cells in Excel, you can use the equal operator by referring to both cells. And in the result, you will get TRUE if both values are the same and if the values are not the same you will get FALSE in the result.

In the following example, we have two values in the cells A1 and B1 respectively, and now, you need to compare both cells.

compare-two-cells

In this tutorial, we will learn about the different methods that you can use.

Compare Two Cells using Equals Operator

  1. First, in cell C1, enter the equal operator to start the formula.
  2. After that, refer to cell A1 where we have the first values.
  3. Next, enter the equal operator to compare values from the cells.
  4. Now, refer to cell B1 where you have the second value.
  5. In the end, hit enter to get the result.
compare-cells-using-equal-operator

As you can see, in the result, we have FALSE which means both values in the cells are not the same. But if you change the value in cell B1 to “Yes”, you will get TRUE in the result.

compared-cells-result

So, this is a simple and quick way to compare two cells and get the result as TRUE or FALSE.

=A1=B1

Using EXACT Function to Match Text Values from Two Cell

There’s also a function in Excel that you can use, and that’s EXACT. With the EXACT function, match text values from two cells and you can refer to the cells that you want to compare, and it will return TRUE or FALSE in the result.

We are using the same example:

  1. First, in cell C1, enter the EXACT function.
  2. After that, refer to cell A1.
  3. Next, enter a comma.
  4. Now, refer to cell B1.
  5. In the end, enter the closing parentheses and hit enter to get the result.
exact-function-to-compare

You can see we have got FALSE in the result as values in cells A1 and B1 are not the same.

=EXACT(A1,B1)

Using the IF Function Create a Condition to Compare Two Values

In both methods that we have discussed above, we get the result in TRUE or FALSE, but, what if you want to have a custom result for both cases? In that case, you can use the IF function to create a condition and get a custom result.

  1. First, in cell C1, enter the IF function.
  2. After that, use the same way to compare cells that we have used in the first method.
  3. Next, in the second argument of the function, enter the value that you want to get if both values match.
  4. Now, in the third argument of the function, enter the value that you want to get if both values do not match.
  5. In the end, enter the closing parentheses and close the function.
using-if-comparing-cells

As you can see, in the result we have the value “Not Matched” as values in both of the cells are not the same.

=IF(A1=B1,"Matched","Not Matched")

Get the Excel File

Leave a Comment