Compare Two Cells in Excel and Return TRUE or FALSE (5 Quick Ways)

While working in Microsoft Excel, often we need to compare two cells. This is a basic operation we do in Excel and luckily, Excel has several options to compare cells. However, this article will guide you on how to compare two cells in Excel and return TRUE or FALSE.


Compare Two Cells in Excel and Return TRUE or FALSE: 5 Quick Ways

Let’s consider a dataset (B5:D10) containing fruit names in two columns (columns B & C). Now, I will compare fruit names between two cells of these columns and thus return TRUE/FALSE accordingly.

5 Quick Ways to Compare Two Cells in Excel and Return TRUE or FALSE

1. Use ‘Equal to’ Sign to Compare Two Cells and Return TRUE or FALSE

We can compare two cells simply using an equal to (=) sign. This is the easiest and most basic way to compare two cells in Excel.

Steps:

  • First, type the below formula in Cell D5 and press Enter from the keyboard.
=B5=C5

Use ‘Equal to’ Sign to Compare Two Cells and Return TRUE or FALSE

  • As a result, you will get the below result because both Cell B5 and C5 contain the same fruit: Watermelon. Now, use the Fill Handle (+) tool to copy the formula to compare the rest of the cells.

Use ‘Equal to’ Sign to Compare Two Cells and Return TRUE or FALSE

  • Finally, you will see the below result. The above formula has returned TRUE/FALSE for each pair of cells depending on their cell contents.


2. Compare Two Cells and Return TRUE or FALSE with Excel EXACT Function

This time, I will use the EXACT function in excel to compare two cells. Usually, the EXACT function checks whether two text strings are exactly the same, and returns TRUE or FALSE  But, remember, the EXACT function is case-sensitive.

Steps:

  • Type the below formula in Cell D5 and hit Enter.
=EXACT(B5,C5)

Compare Two Cells and Return TRUE or FALSE with Excel EXACT Function

  • Consequently, we will get the below result. I have used the Fill Handle tool to copy the above formula over the range D6:D11.


3. Excel COUNTIF Function to Compare Two Cells and Get TRUE/FALSE

You can use the COUNTIF function to compare two cells in Excel and thus return TRUE or FALSE.

Steps:

  • Type the below formula in Cell D5 and press Enter.
=COUNTIF(B5:C5,B5)=2

Excel COUNTIF Function to Compare Two Cells and Get TRUE/FALSE

  • As a consequence, we will receive the below output. Similar to previous methods, use the Fill Handle tool to copy the above formula to compare the rest of the cells.

Here, the COUNTIF function counts the number of cells within the range B5:C10, for the given condition B5:C10=B5. And, 2 refers to the number of cells you want to check for. For instance, if I have to compare three cells I will type the formula as =COUNTIF(B5:D5,B5)=3.


4. Use IF Function to Compare Two Cells and Return TRUE or FALSE in Excel

We can compare two cells easily by using the IF function in Excel. We can provide TRUE and FALSE as the arguments in the IF function. So, let’s follow the below steps to do the task.

Steps:

  • Type the below formula in Cell D5 and hit Enter.
=IF(B5=C5,"TRUE","FALSE")

Use IF Function to Compare Two Cells and Return TRUE or FALSE in Excel

  • Upon entering the formula, here is the result we receive. Use the Fill Handle tool to copy the formula to the rest of the cells.

Here, the IF function checks whether one cell value is equal to another (e.g. B5=C5), and returns TRUE if the above condition is met. On the other hand, the function returns FALSE if cell values are not equal.


5. Combine VLOOKUP and ISERROR Functions to Compare Two Cells and Get FALSE in Return

Now, I will use the VLOOKUP function to compare two cells in Excel. However, If we compare two cells merely using the VLOOKUP function, the #N/A error occurs if values are not similar in cells. So, to avoid the error, I will use the IFERROR function along with the VLOOKUP function.

Steps:

  • Type the below formula in Cell D5 and press Enter.
=IFERROR(VLOOKUP(C5,$B$5:$B$10,1,0),"FALSE")

Combine VLOOKUP and ISERROR Functions to Compare Two Cells and Get FALSE in Return

  • Consequently, we will get the below output. I have used the Fill Handle tool to compare other cells in the dataset.

🔎 How Does the Formula Work?

  • (VLOOKUP(C5,$B$5:$B$10,1,0)

Here, the VLOOKUP function looks for the value of Cell B5 in the range B5:B10 returns:

{#N/A}

  • IFERROR(VLOOKUP(C5,$B$5:$B$10,1,0),”FALSE”)

Later, to avoid the error, we wrapped the VLOOKUP formula with the IFERROR function, and the formula returns:

{FALSE}


Download Practice Workbook


Conclusion

In the above article, I have tried to discuss several methods to compare two cells in Excel and return TRUE/FALSE. Hopefully, these methods and explanations will be enough to solve your problems. Please let me know if you have any queries.


<< Go Back To Excel Compare Cells | Compare in Excel | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Hosne Ara
Hosne Ara

Hosne Ara is a materials and metallurgical engineer who loves exploring Excel and VBA programming. To her, programming is like a time-saving superhero for dealing with data, files, and the internet. She's skilled in Rhino3D, Maxsurf C++, MS Office, AutoCAD, and Excel & VBA, going beyond the basics. With a B. Sc. in Materials and Metallurgical Engineering from Bangladesh University of Engineering and Technology, she's shifted gears and now works as a content developer. In this role, she... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo