Академический Документы
Профессиональный Документы
Культура Документы
The one query that I get a lot is – ‘how to compare two columns in Excel?’.
This can be done in many different ways, and the method to use will depend on the data str
and what the user wants from it.
For example, you may want to compare two columns and find or highlight all the matching d
points (that are in both the columns), or only the differences (where a data point is in one c
and not in the other), etc.
Since I get asked about this so much, I decided to write this massive tutorial with an intent
cover most (if not all) possible scenarios.
https://trumpexcel.com/compare-two-columns/ 1/31
8/29/2019 How to Compare Two Columns in Excel (for matches & differences)
Note that the techniques to compare columns shown in this tutorial are not the only ones.
Based on your dataset, you may need to change or adjust the method. However, the basic
principles would remain the same.
If you think there is something that can be added to this tutorial, let me know in the comme
section
https://trumpexcel.com/compare-two-columns/ 2/31
8/29/2019 How to Compare Two Columns in Excel (for matches & differences)
If there is a match, I need the result as “TRUE”, and if doesn’t match, then I need the result
“FALSE”.
=A2=B2
https://trumpexcel.com/compare-two-columns/ 3/31
8/29/2019 How to Compare Two Columns in Excel (for matches & differences)
=IF(A2=B2,"Match","Mismatch")
https://trumpexcel.com/compare-two-columns/ 4/31
8/29/2019 How to Compare Two Columns in Excel (for matches & differences)
Note: In case you want to make the comparison case sensitive, use the following IF formula
=IF(EXACT(A2,B2),"Match","Mismatch")
With the above formula, ‘IBM’ and ‘ibm’ would be considered two different names and the a
formula would return ‘Mismatch’.
https://trumpexcel.com/compare-two-columns/ 5/31
8/29/2019 How to Compare Two Columns in Excel (for matches & differences)
5. In the ‘New Formatting Rule’ dialog box, click on the ‘Use a formula to determine which c
format’.
https://trumpexcel.com/compare-two-columns/ 6/31
8/29/2019 How to Compare Two Columns in Excel (for matches & differences)
https://trumpexcel.com/compare-two-columns/ 7/31
8/29/2019 How to Compare Two Columns in Excel (for matches & differences)
7. Click the Format button and specify the format you want to apply to the matching cells.
×
8. Click OK.
This will highlight all the cells where the names are the same in each row.
If you want to compare two columns and highlight matching data, you can use the duplicate
×
functionality in conditional formatting.
Note that this is different than what we have seen when comparing each row. In this case, w
not be doing a row by row comparison.
Note that the list in column A is bigger than the one in B. Also some names are there in bot
lists, but not in the same row (such as IBM, Adobe, Walmart).
If you want to highlight all the matching company names, you can do that using conditional
formatting.
https://trumpexcel.com/compare-two-columns/ 9/31
8/29/2019 How to Compare Two Columns in Excel (for matches & differences)
https://trumpexcel.com/compare-two-columns/ 10/31
8/29/2019 How to Compare Two Columns in Excel (for matches & differences)
8. Click OK.
The above steps would give you the result as shown below.
Note: Conditional Formatting duplicate rule is not case sensitive. So ‘Apple’ and ‘apple’ are
considered the same and would be highlighted as duplicates.
https://trumpexcel.com/compare-two-columns/ 11/31
8/29/2019 How to Compare Two Columns in Excel (for matches & differences)
https://trumpexcel.com/compare-two-columns/ 12/31
8/29/2019 How to Compare Two Columns in Excel (for matches & differences)
8. Click OK.
https://trumpexcel.com/compare-two-columns/ 13/31
8/29/2019 How to Compare Two Columns in Excel (for matches & differences)
This will give you the result as shown below. It highlights all the cells that have a name that
×
not present on the other list.
Suppose you have a dataset as shown below and you want to identify companies that are p
in column A but not in Column B,
https://trumpexcel.com/compare-two-columns/ 14/31
8/29/2019 How to Compare Two Columns in Excel (for matches & differences)
=ISERROR(VLOOKUP(A2,$B$2:$B$10,1,0))
This formula uses the VLOOKUP function to check whether a company name in A is present
column B or not. If it is present, it will return that name from column B, else it will return a
error.
These names which return the #N/A error are the ones that are missing in Column B.
ISERROR function would return TRUE if there is the VLOOKUP result is an error and FALSE if
an error.
https://trumpexcel.com/compare-two-columns/ 15/31
8/29/2019 How to Compare Two Columns in Excel (for matches & differences)
If you want to get a list of all the names where there is no match, you can filter the result c
to get all cells with TRUE.
=NOT(ISNUMBER(MATCH(A2,$B$2:$B$10,0)))
Note: Personally, I prefer using the Match function (or the combination of Index/Match) inst
VLOOKUP. I find it more flexible and powerful. You can read the difference between Vlookup
Index/Match here.
https://trumpexcel.com/compare-two-columns/ 16/31
8/29/2019 How to Compare Two Columns in Excel (for matches & differences)
For example, in the below list, I want to fetch the market valuation value for column 2. To
× d
I need to look up that value in column 1 and then fetch the corresponding market valuation
=VLOOKUP(D2,$A$2:$B$14,2,0)
or
=INDEX($A$2:$B$14,MATCH(D2,$A$2:$A$14,0),2)
https://trumpexcel.com/compare-two-columns/ 17/31
8/29/2019 How to Compare Two Columns in Excel (for matches & differences)
These lookup formulas need an exact match to give the right result. There is an approximat
match option in VLOOKUP or MATCH function, but that can’t be used here.
Suppose you have the data set as shown below. Note that there are names that are not com
in Column 2 (such as JPMorgan instead of JPMorgan Chase and Exxon instead of ExxonMobi
https://trumpexcel.com/compare-two-columns/ 18/31
8/29/2019 How to Compare Two Columns in Excel (for matches & differences)
In such a case, you can use a partial lookup by using wildcard characters.
The following formula will give is the right result in this case:
=VLOOKUP("*"&D2&"*",$A$2:$B$14,2,0)
or
=INDEX($A$2:$B$14,MATCH("*"&D2&"*",$A$2:$A$14,0),2)
https://trumpexcel.com/compare-two-columns/ 19/31
8/29/2019 How to Compare Two Columns in Excel (for matches & differences)
In the above example, asterisk (*) is a wildcard character that can represent any number of
characters. When the lookup value is flanked with it on both sides, any value in Column 1 w
contains the lookup value in Column 2 would be considered as a match.
For example, *Exxon* would be a match for ExxonMobil (as * can represent any number of
characters).
You May Also Like the Following Excel Tips & Tutorials:
https://trumpexcel.com/compare-two-columns/ 20/31