Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Compare Two Columns in Excel for Matches

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

To compare two columns for matches in Excel, put a formula next to your data that tests one cell against the other column, then fill it down. The simplest version is =A2=B2, which returns TRUE when the values match and FALSE when they do not. For anything more than a quick visual check, use =IF(A2=B2,"Match","No match") so the result is readable, or =COUNTIF($B$2:$B$1000,A2)>0 when the columns are different lengths or in a different order. That single formula handles most real-world jobs, and the rest of this guide covers the variations.

What You'll Need

  • Excel on Windows, Mac, or Excel for the web. The formulas below work identically on all three.
  • Two columns of data, ideally each with a header row so you can see what you are comparing.
  • An empty column beside your data to hold the result formula. Insert one first if the neighbouring column is occupied (right-click the column letter and choose Insert).
  • A decision on whether matching should be case-sensitive, because the default is not.

Step-by-Step

  1. Clean the obvious problems first. Select each column and remove leading or trailing spaces with Find and Replace: press Ctrl+H (Cmd+H on Mac), type a space in "Find what", leave "Replace with" empty, and replace. If you suspect double spaces, repeat with two spaces. Stray spaces are the single most common reason two values that look identical fail to match.
  2. Click the first empty cell beside your first data row. If your data starts in row 2, use C2 or D2, whichever column is free. Do not put the formula in the header row.
  3. Type the basic comparison. For a straightforward row-by-row check, enter =IF(A2=B2,"Match","No match") and press Enter. This compares A2 with B2 only, which is what you want when the two lists are in the same order.
  4. Fill the formula down the whole column. Click the cell, then double-click the small square at the bottom-right corner of the selection (the fill handle). Excel fills down automatically as far as the adjacent data goes. If that does nothing, drag the handle manually, or select the range and press Ctrl+D.
  5. Read the results. "Match" rows are present in both columns at the same position. "No match" usually means either a genuine difference or a formatting problem such as text stored as numbers (see Troubleshooting).
  6. Switch to a lookup formula if the columns are out of order or different lengths. Replace the formula with =IF(COUNTIF($B$2:$B$1000,A2)>0,"Found","Missing"). This asks whether each value in column A appears anywhere in column B, regardless of position. Adjust the range to cover your actual data and keep the dollar signs so the range stays locked when you fill down.
  7. Go the other way too, if you need to. Put =IF(COUNTIF($A$2:$A$1000,B2)>0,"Found","Missing") next to column B to find values that exist in B but not A. Comparing in both directions is the only way to find every difference.
  8. Filter for the results you care about. Select your header row and turn on a filter (Data > Filter), then use the filter arrow on the result column to show only "No match" or "Missing". Copy those visible rows somewhere else if you need to act on them.
  9. Highlight matches with colour instead of formulas (optional). If you only want a visual read, select both columns, go to Home > Conditional Formatting > Highlight Cells Rules > Duplicate Values, and choose a fill colour. Note that this highlights duplicates within each column as well as across them, so it is not a precise cross-column match test. For a precise one, use Home > Conditional Formatting > New Rule > Use a formula, with a formula such as =COUNTIF($B$2:$B$1000,$A2)>0 applied to the range you want highlighted.
  10. Turn the results into plain values before you sort or share. Copy the result column, then Paste Special > Values over itself. Sorting with live formulas can leave rows out of step with their results, and pasted values travel safely to other sheets.

Common Mistakes

  • Forgetting the dollar signs. Without $ on the lookup range, the range slides down as you fill and the formula starts checking the wrong cells. This produces results that look plausible but are wrong.
  • Chopping off the bottom of the list. If you hard-code $B$2:$B$100 but the list now runs to row 300, everything below row 100 reports as missing. Use a range larger than your data or convert the columns to a table.
  • Trusting a match without checking case. Excel's equals comparison ignores capitalisation, so "Apple" and "apple" count as a match. If case matters, use =IF(EXACT(A2,B2),"Match","No match") or =SUMPRODUCT(--EXACT($B$2:$B$1000,A2))>0.
  • Leaving stray spaces or non-breaking spaces. A normal Find and Replace removes regular spaces but not non-breaking spaces (character 160), which often arrive with web-pasted data. Use =TRIM(SUBSTITUTE(A2,CHAR(160)," ")) to normalise them.
  • Comparing numbers to text. A number stored as text looks identical on screen but never equals a real number. Realign it with =VALUE() or Data > Text to Columns.
  • Assuming empty cells match. Two blanks compare as equal, so blank rows show up as "Match" and can disguise real gaps in the data.

Tips

  • Format results as a two-colour highlight: apply Conditional Formatting with a Cell Value rule on the result column so "No match" is shaded red, then you can scan a long sheet instantly.
  • Use a unique suffix in the result column header such as "Match flag" so the meaning is clear when you send the file to someone else.
  • For three-way checks, chain the formulas: =IF(COUNTIF($B$2:$B$1000,A2)=0,"Missing in B",IF(COUNTIF($C$2:$C$1000,A2)=0,"Missing in C","Match all")).
  • If you upgrade to Microsoft 365 and want one dynamic formula, XLOOKUP can confirm a match: =IF(XLOOKUP(A2,$B$2:$B$1000,$B$2:$B$1000,"Missing")="Missing","Missing","Match"). The COUNTIF version works in every version of Excel.

Troubleshooting

If the results look wrong, work through these checks in order. First, confirm the formulas reference the right rows: click one result cell and look at the formula bar. If it says A7=B7 while you expected row 2, the fill was done before the data was in place. Second, test a single suspected mismatch by comparing lengths: =LEN(A2) and =LEN(B2) next to each other. If the lengths differ but the text looks the same, you have invisible characters. Third, select the column and look at the alignment: text sits left, numbers sit right. Mixed alignment between the two columns means mixed types.

If every row reports "No match", check whether one column uses a different variant such as trailing full stops, different date formats, or a prefix like a currency symbol. If conditional formatting highlights the wrong cells, confirm the rule window shows the exact range you intended, because Excel expands or shifts rules when rows are inserted. If Find and Replace does not remove spaces, use the TRIM formula in a helper column, then copy and Paste Special > Values over the original.

Frequently Asked Questions

How do I compare two columns and return the values that are different?

Use =IF(A2<>B2,A2,"") to display the column A value only when the row differs, or filter the "No match" results as above.

Can I find which values in column A are missing from column B?

Yes. =IF(COUNTIF($B$2:$B$1000,A2)=0,"Missing","") next to each column A row returns "Missing" when the value does not appear anywhere in B.

Does comparing columns work the same on Excel for the web and on Mac?

The formulas are identical. Menu names for Filter, Conditional Formatting and Paste Special are the same, though minor wording differences can appear between versions, devices and regions.

Why do two cells that look identical not match?

Usually an invisible character such as a leading space, a non-breaking space, or a number stored as text. Wrapping the values in TRIM or checking with LEN reveals the culprit.

Can I compare more than two columns at once?

Yes, by chaining COUNTIF or IF statements, but write the checks one column at a time so you can see which comparison fails.