formulahelper

How to compare two columns in Excel

Comparing two columns usually means one question: which entries of the first column cannot be found anywhere in the second? The order of rows does not matter and the columns may have different lengths. A short formula next to the first column answers it row by row.

Worked example on made-up data

A small example: two lists, the formula our tool produced for them and the result of computing it. The data is invented for the example.

Ordered and shipped SKU codes with a third column that says missing next to the codes that were not shipped
Sheet snapshot: the example computed in LibreOffice Calc (made-up data). In Excel and Google Sheets you enter the formula the same way; the interface looks different.

Formula for Excel

=IF(A2="","",IF(ISNA(MATCH(A2,$B$2:$B$6,0)),"missing",""))

The formula was verified by computing it on this example (7 rows in the first list, 5 in the second): the result equals the reference answer. The example was also recomputed in LibreOffice Calc with the same result.

MATCH looks for the value of A2 in $B$2:$B$6; if it is not there MATCH returns #N/A, and ISNA turns that into 'not found'. Rows whose value is missing from the second list get "missing". Blank rows of the first list are not flagged. Paste the formula into C2 and fill it down to the end of $A$2:$A$8.

Other verified variants

  • SUMPRODUCT =IF(A2="","",IF(SUMPRODUCT(($B$2:$B$6=A2)*($B$2:$B$6<>""))=0,"missing",""))
  • COUNTIF =IF(A2="","",IF(COUNTIF($B$2:$B$6,A2)=0,"missing",""))

Values of the first list that are not in the second (3)

SKU-210, SKU-212, SKU-215

Compare your own lists

The tool below is already set up for this task. Paste your columns to get a formula for your version and the list, both checked by computing. 3 free comparisons a day, no sign-up.

What to find
Spreadsheet
Excel version
Formula language
How to compare
Output
Addresses and wishes (optional)
Free comparisons left today: 3

Pro for $7/month

Pro is coming — leave nothing, we just count interest.

What the formula does

MATCH with a zero as its last argument looks for the exact value of A2 in the second column. When the value is there, MATCH returns its position; when it is not, MATCH returns #N/A. ISNA turns that error into TRUE, and IF writes the word missing. The A2="" test keeps blank rows from being flagged.

In the example seven SKUs were ordered and five codes appear in the shipping list, one of which (SKU-220) was never ordered. The flag lands on SKU-210, SKU-212 and SKU-215 — the three orders that have not left the warehouse yet.

Step by step

  1. Click the first empty cell to the right of your first column, here C2.
  2. Paste the formula and change the ranges to your own; keep the dollar signs on the second range.
  3. Press Enter. It is a regular formula in every version from Excel 2010 to Microsoft 365.
  4. Double-click the fill handle to copy the formula down to the last row.
  5. Turn on a filter (Data → Filter) and pick missing to see only the gaps.

Checking both directions

The flag answers one direction only. To find codes that are in the second column but not in the first — like SKU-220 here — swap the roles: put the formula next to column B and search column A. In the tool you simply paste the lists the other way round.

Same-row comparison is a different task

If you need to know whether A2 equals B2, A3 equals B3 and so on, =A2=B2 is enough and returns TRUE or FALSE. That works only when both columns are sorted identically. When they are not, you need the lookup approach shown on this page.

Common mistakes

Trailing spaces from exports

A code exported as "SKU-211 " with a trailing space will not match "SKU-211". Tick "Ignore spaces" and the formula wraps both sides in TRIM.

Codes that look like numbers

If one column stores 1045 as a number and the other as text, MATCH treats them as different values. Tick "Numbers and text are equal" or convert one column first.

Wildcard characters

MATCH reads * and ? as patterns, so "A?1" would match "AB1". If your codes contain these characters, the tool switches to a SUMPRODUCT comparison that has no wildcards.

Questions and answers

Is the comparison case-sensitive?

No, MATCH ignores letter case. Tick "Match case" if Code and CODE must be different; the formula then uses EXACT.

Can I get a separate list of the missing values instead of flags?

Yes, choose "Separate list". Excel 2021 and 365 get a FILTER formula; older versions get an INDEX/SMALL array formula.

Do I need to sign up?

No. Three comparisons a day are free without an account, and the lists are not stored.