If you work with data, I’m sure you’ve needed to compare two columns in Excel at some point. Whether you’re a data scientist or just someone who spends a lot of time with spreadsheets, knowing how to efficiently compare columns can save you a lot of time and effort. In this guide, we will explore various methods to compare two columns in Excel, through working examples.
Learn More: Microsoft Excel for Data Analysis
There are 5 different ways in which you can compare the contents of two columns in Excel.
Let’s say you have two columns, A and B, filled with names, and you want to highlight names in Column B that do not appear in Column A.
Steps:
=ISERROR(MATCH(B1, $A$1:$A$10, 0))
.Example:
Column A | Column B |
Alice | Bob |
Bob | Alice |
Charlie | Dave |
Dave | Charlie |
Eve | Frank |
After applying conditional formatting, “Frank” in Column B would be highlighted, indicating it does not appear in Column A.
Here’s how to find which values in Column A match those in Column B.
Steps:
=IF(A1=B1, "Match", "No Match")
.Example:
Column A | Column B | Column C |
Alice | Bob | No Match |
Bob | Alice | No Match |
Charlie | Charlie | Match |
Dave | Dave | Match |
Eve | Frank | No Match |
Suppose you want to see if values in Column A exist in Column B and retrieve related data.
Steps:
=IF(ISNA(VLOOKUP(A1, $B$1:$B$10, 1, FALSE)), "Not Found", "Found")
.Example:
Column A | Column B | Column C |
Alice | Bob | Found |
Bob | Alice | Found |
Charlie | Dave | Found |
Dave | Charlie | Found |
Eve | Frank | Not Found |
If you want to compare text values in Columns A and B, considering case sensitivity, here’s how you can do it.
Steps:
=EXACT(A1, B1)
.Example:
Column A | Column B | Column C |
Alice | alice | FALSE |
Bob | Bob | TRUE |
Charlie | charlie | FALSE |
Dave | Dave | TRUE |
Eve | Eve | TRUE |
Here’s how you can count how many times each value in Column A appears in Column B.
Steps:
=COUNTIF($B$1:$B$10, A1)
.Example:
Column A | Column B | Column C |
Alice | Bob | 1 |
Bob | Alice | 1 |
Charlie | Dave | 1 |
Dave | Charlie | 1 |
Eve | Frank | 0 |
As you have seen in this article, you can compare columns in Excel in many different ways. Each method has its unique advantages and the one you choose depends on your use case. If all you need is a quick visual check, conditional formatting is the best method. For more precise comparisons you can use functions and formulas like COUNTIF, EXACT, VLOOKUP, or IF. With some practice, you can find out which ones best suit your needs and use them to streamline your workflow.
Master Excel functions in 2 hours: Microsoft Excel Tutorial for Beginners
A. You can use conditional formatting to find the differences between two columns in Excel. Here’s the formula for it: =ISERROR(MATCH(B1, $A$1:$A$10, 0))
A. Yes, you can use the COUNTIF
function or conditional formatting to find duplicates between two columns.
A. The most commonly used method to compare two columns in Excel is the IF
function. It is written as =IF(A1=B1, "Match", "No Match")
. However, for more complex comparisons, you can use the VLOOKUP
or EXACT
function.
A. You can use VLOOKUP along with IF
and ISNA
to find matches between two columns in Excel: =IF(ISNA(VLOOKUP(A1, $B$1:$B$10, 1, FALSE)), "Not Found", "Found")
.
A. Yes, you can use Excel’s built-in tools like conditional formatting to visually compare two columns without writing formulas.