How to Compare Two Columns in Excel
The fastest way to compare two columns in Excel depends on what you want to find:
| Goal | Best method |
|---|---|
| Mark whether each value exists in another column | COUNTIF |
| Return related data from the matching row | XLOOKUP |
| Highlight matching or different cells visually | Conditional Formatting |
| Create a separate list of missing values | FILTER |
| Compare row by row | A simple equality formula |
For most list comparison tasks, start with COUNTIF:
=IF(COUNTIF($D$2:$D$100,A2)>0,"Found","Missing")This checks whether the value in A2 appears anywhere in column D.
If a match depends on two or more fields, see COUNTIF vs COUNTIFS in Excel for the multi-condition pattern.
1. Example Data
Suppose column A contains product IDs from a new order file, and column D contains product IDs from your master product list.
| New Order IDs | Master Product IDs | |
|---|---|---|
| P-101 | P-101 | |
| P-205 | P-318 | |
| P-999 | P-427 | |
| P-318 | P-512 |
You want to know which new order IDs already exist in the master list and which ones are missing.
2. Compare Two Columns with COUNTIF
Use COUNTIF when you want a simple found/missing result.
=IF(COUNTIF($D$2:$D$100,A2)>0,"Found","Missing")Result:
| New Order ID | Status |
|---|---|
| P-101 | Found |
| P-205 | Missing |
| P-999 | Missing |
| P-318 | Found |
How it works:
| Formula part | Meaning |
|---|---|
$D$2:$D$100 |
The list to search |
A2 |
The value to look for |
>0 |
Any count above zero means the value exists |
"Found" / "Missing" |
Labels shown in the result |
Lock the lookup range with dollar signs before copying the formula down. If references shift when copied, review Excel cell references.
For more counting patterns, see the Excel COUNT function tutorial.
3. Find Values in Column A That Are Missing from Column D
To flag only values that do not appear in the second list, use:
=IF(COUNTIF($D$2:$D$100,A2)=0,"Missing","")This is useful when the missing items are the only rows you want to review.
| New Order ID | Missing? |
|---|---|
| P-101 | |
| P-205 | Missing |
| P-999 | Missing |
| P-318 |
If your list has extra spaces, inconsistent capitalization, or imported text issues, clean the data first with Excel Data Cleaning.
4. Compare Two Columns Row by Row
Use a row-by-row comparison when each row should match the same row in another column.
=IF(A2=B2,"Match","Different")Example:
| System A | System B | Result |
|---|---|---|
| P-101 | P-101 | Match |
| P-205 | P-205 | Match |
| P-318 | P-999 | Different |
This method does not search the whole second column. It only compares A2 with
B2, then A3 with B3, and so on.
5. Highlight Matches or Differences with Conditional Formatting
Conditional Formatting is best when you want visual review instead of a helper column.
To highlight values in column A that also appear in column D:
- Select
A2:A100. - Go to Home > Conditional Formatting > New Rule.
- Choose "Use a formula to determine which cells to format."
- Enter this formula:
=COUNTIF($D$2:$D$100,A2)>0- Choose a fill color and click OK.
To highlight values in column A that are missing from column D, use:
=COUNTIF($D$2:$D$100,A2)=0For more formatting examples, see Excel conditional formatting.
6. Return Matching Data with XLOOKUP
Use XLOOKUP when comparison is not enough and you need to return related data.
Suppose the master list has Product ID in column D and Category in column E:
| Product ID | Category |
|---|---|
| P-101 | Accessories |
| P-318 | Accessories |
| P-427 | Office |
To return the category for the ID in A2:
=XLOOKUP(A2,$D$2:$D$100,$E$2:$E$100,"Missing")If the product exists, Excel returns the category. If not, it returns
Missing.
For a deeper walkthrough, use the Excel XLOOKUP tutorial.
7. Compare Two Columns with VLOOKUP
If you need compatibility with older Excel files, VLOOKUP can also check whether values in one column appear in another column.
=IFNA(VLOOKUP(A2,$D$2:$D$100,1,FALSE),"Missing")This returns the matching value if found and Missing if not found.
For a clearer label:
=IF(ISNA(VLOOKUP(A2,$D$2:$D$100,1,FALSE)),"Missing","Found")If VLOOKUP returns #N/A unexpectedly, see
How to Fix VLOOKUP #N/A in Excel.
8. Create a List of Missing Values with FILTER
If you use Microsoft 365 or newer Excel, FILTER can return a separate list of
values from column A that do not appear in column D.
=FILTER(A2:A100,COUNTIF(D2:D100,A2:A100)=0,"No missing values")This spills all missing values into a clean output list.
| Missing from master list |
|---|
| P-205 |
| P-999 |
Use this when you want a reusable exception report instead of row-by-row labels. For more dynamic examples, see the Excel FILTER function tutorial.
9. Compare Two Columns and Find Duplicates
Sometimes "compare two columns" really means "find values that appear more than
once." Use COUNTIF to flag repeated values:
=IF(COUNTIF($A$2:$A$100,A2)>1,"Duplicate","Unique")This checks duplicates inside one column. To compare duplicates across two lists, use the found/missing formulas above, then review repeated values before deleting anything.
For a safer cleanup workflow, see How to Remove Duplicates in Excel. For a review-first duplicate workflow, use How to Find Duplicates in Excel.
10. Common Problems When Comparing Columns
If your formulas return unexpected results, check these common issues:
| Problem | Symptom | Fix |
|---|---|---|
| Extra spaces | Values look the same but show as missing | Use TRIM on both lists |
| Numbers stored as text | IDs such as 1001 do not match |
Convert both columns to the same type |
| Different formats | Dates or codes look similar but differ internally | Standardize formats before comparing |
| Hidden duplicates | COUNTIF returns more than one match |
Review duplicates before using lookup results |
| Formula range shifted | Formula works in the first row only | Lock ranges with $ |
To test whether two values are truly identical, use:
=A2=B2If the result is FALSE, the cells are not identical even if they look similar.
11. Which Method Should You Use?
Use this decision table:
| Need | Use |
|---|---|
| Quick found/missing status | COUNTIF |
| Visual review | Conditional Formatting |
| Return related fields | XLOOKUP |
| Older workbook compatibility | COUNTIF or VLOOKUP |
| Spill a clean missing-values list | FILTER |
| Compare same-row values | =A2=B2 or IF(A2=B2,...) |
Start with the simplest method that answers the question. If you only need to
know whether a value exists, COUNTIF is usually enough. If you need to bring
back related data, move to XLOOKUP.
12. Practice Example
Use these lists:
| Sales IDs | Approved IDs | |
|---|---|---|
| C-101 | C-101 | |
| C-205 | C-318 | |
| C-318 | C-427 | |
| C-999 | C-512 |
Tasks:
| Task | Formula |
|---|---|
| Mark each Sales ID as Found or Missing | =IF(COUNTIF($D$2:$D$5,A2)>0,"Found","Missing") |
| Show only missing Sales IDs | =FILTER(A2:A5,COUNTIF(D2:D5,A2:A5)=0,"No missing values") |
| Return the matching ID with XLOOKUP | =XLOOKUP(A2,$D$2:$D$5,$D$2:$D$5,"Missing") |
Reference answers:
| Sales ID | Status |
|---|---|
| C-101 | Found |
| C-205 | Missing |
| C-318 | Found |
| C-999 | Missing |
13. Summary
To compare two columns in Excel, use COUNTIF for found/missing checks,
Conditional Formatting for visual review, XLOOKUP when you need to return
related data, and FILTER when you want a separate list of missing values. Before
trusting the result, clean extra spaces, check data types, and lock your ranges
before copying formulas down.
14. Related Guides
- Return matching data with the Excel XLOOKUP tutorial.
- Choose between lookup values and matching-row reports with Excel FILTER vs VLOOKUP.
- Learn more
COUNTIFexamples in the Excel COUNT function tutorial. - Decide when a list check needs multiple criteria with COUNTIF vs COUNTIFS in Excel.
- Build dynamic missing-value lists with the Excel FILTER function tutorial.
- Clean repeated records with How to Remove Duplicates in Excel.
- Review repeated values first with How to Find Duplicates in Excel.
- Fix missing lookup results with How to Fix VLOOKUP #N/A in Excel.
- Review Excel conditional formatting for visual comparison workflows.
Need help fixing a formula?
Share the formula, a small sample table, and the result you expected. This free beta helps us learn which Excel problems readers actually need solved.
Ask for formula help