The fastest way to test that two values do not match in Excel is the not-equal operator, written as <>. A formula like =IF(A2<>B2,"Different","Same") returns "Different" whenever the two cells disagree and "Same" when they are identical. You can also use IF(COUNTIF(range,value)=0,...) when you want to check a value against an entire list rather than a single cell.

That one operator solves most real-world cases: comparing two columns, flagging rows that changed between versions of a sheet, or spotting IDs missing from a master list. The rest of this guide shows the variations, the gotchas that make two values look identical when they are not, and how to fix them.

What You'll Need

  • Microsoft Excel on Windows, macOS, the web app, or Google Sheets (the IF syntax below works the same in all of them)
  • Two cells or two ranges you want to compare
  • A basic understanding of how to type a formula starting with = and press Enter

Step-by-Step

  1. Decide what "does not match" means for your data. Do you want to compare one cell to one other cell (row by row), or check whether a single value appears anywhere in a list? The formula is different for each. Row-by-row comparison uses <>; list lookup uses COUNTIF or MATCH.
  2. Write the basic not-equal test. Click an empty cell beside your data and type =A2<>B2. Press Enter. You get TRUE when the values differ and FALSE when they match. This is the raw building block; everything else wraps it in IF.
  3. Wrap it in IF for readable output. Change the formula to =IF(A2<>B2,"Does not match","Match"). The second argument is the value returned when the condition is true (the cells differ), and the third is returned when false. Use text in quotes; use numbers without quotes if you want a numeric result.
  4. Copy it down the column. Click the small square at the bottom-right corner of the cell to drag the formula down, or double-click that square to fill to the end of the adjacent data. Each row's references adjust automatically unless you have made them absolute with $.
  5. Lock one side when comparing against a single reference cell. If you compare every row to one fixed cell, such as $D$1, type =IF(A2<>$D$1,"Does not match","Match") before filling down. The dollar signs stop that reference from shifting, which is the single most common source of wrong results after copying.
  6. Use COUNTIF when checking against a list. To flag values in column A that do not appear in column D, use =IF(COUNTIF($D$2:$D$100,A2)=0,"Not in list","Found"). A zero count means no match, so this is the standard way to find missing records. Keep the range absolute so the fill handles it consistently.
  7. Return a blank instead of a label if you prefer. Swap the text for empty quotes: =IF(A2<>B2,"Mismatch",""). This keeps the sheet clean so only problem rows show a label, which makes scanning long lists far quicker.
  8. Add colour with conditional formatting. Select your data, open Home > Conditional Formatting > New Rule, choose "Use a formula to determine which cells to format" and enter a rule such as =$A2<>$B2 applied to the whole range. This highlights mismatches directly on the data rather than in a helper column. Note that menu labels vary slightly by Excel version and platform.
  9. Trim spaces if results look wrong. Wrap each side in TRIM: =IF(TRIM(A2)<>TRIM(B2),"Does not match","Match"). Excel treats a trailing space as a different character, so "Apple" and "Apple " count as a mismatch. TRIM removes extra spaces between words too, which also catches copy-paste spacing problems.
  10. Make the comparison case-insensitive if needed. The <> operator ignores letter case, so "apple" and "APPLE" already match. If case genuinely matters, use =IF(EXACT(A2,B2),"Match","Does not match"), since EXACT is case-sensitive.
  11. Compare numbers stored as text. If one column is text-formatted and the other numeric, 3 and "3" will not match. Convert with VALUE or by using Text to Columns on the Home tab, or compare with =IF(A2&""<>B2&"",...) to force both sides to text.
  12. Find the first mismatch position for longer text. If you only need to know whether any character differs, =IF(EXACT(A2,B2),"Same","Different") is enough. To see where they diverge, compare lengths with LEN(A2)<>LEN(B2) first; a length difference tells you it is not just a spacing issue.
  13. Test your formula on a known pair. Before filling 500 rows, make one deliberate match and one deliberate mismatch and confirm the formula returns the right label for each. This catches reversed TRUE/FALSE arguments instantly.

Common Mistakes

  • Using != instead of <>. Excel does not recognise the exclamation-mark operator; that belongs to programming languages and Google Sheets accepts it, but Excel needs the angle brackets.
  • Forgetting the quotes around text. Writing =IF(A2<>B2,Different,Same) makes Excel look for named ranges called Different and Same and return errors. Text arguments must be in double quotes.
  • Relative references that shift on fill. Copying =IF(A2<>D1,...) down gives D2, D3 and so on. Add $ to keep a fixed reference.
  • Invisible spaces and non-breaking spaces. Data pasted from websites or PDFs often contains characters TRIM cannot remove. Use CLEAN in combination, or replace non-breaking spaces with Find and Replace.
  • Comparing a whole range with a single cell. A2:A10<>B2 spills or returns unexpected results. Compare one cell at a time, or use SUMPRODUCT(--(A2:A10<>B2)) to count mismatches.
  • Mistaking TRUE/FALSE for an error. A raw logical formula shows TRUE when the values differ; that is correct behaviour, not a mistake.
  • Unintended conditional formatting ranges. Check the "Applies to" box in the rule manager; a wrong range highlights cells you did not intend to test.

Tips

  • Pipe both sides through TRIM and CLEAN in one go: =IF(TRIM(CLEAN(A2))<>TRIM(CLEAN(B2)),"Does not match","Match").
  • Use IFERROR around formulas that can fail, such as =IFERROR(IF(MATCH(A2,$D$2:$D$100,0)>0,"Found","Not in list"),"Not in list"), so errors read as a clean label.
  • Keep helper results in their own column and leave the source data untouched; it makes review and undo far easier.
  • To find duplicates in one column instead, the same COUNTIF logic with a count greater than one does the job.
  • If you are comparing two lists, sort both by the same key first so visual review of mismatches is fast.
  • Use Ctrl+` on Windows or Ctrl+~ on Mac to toggle and reveal formulas on the sheet for a quick audit.

Troubleshooting

Every row shows "Does not match" when some should match. Check for trailing spaces first, then check number-versus-text formatting. Select each cell and look at the alignment: text defaults left, numbers default right. If one side is left-aligned in a numeric comparison, that is your culprit.

The formula returns #NAME?. You have almost certainly used unquoted text or misspelled a function name. Check both arguments after the comma.

Results change after copying down. Your references shifted. Add dollar signs to the fixed reference and re-fill from the original cell.

No cells are highlighted by the conditional formatting rule. Confirm the rule's formula starts with =, that it uses a relative row reference for the top-left cell of the applied range, and that the rule is not disabled or overridden by an earlier rule in the list.

Two values look identical but compare as different. Compare their lengths with =LEN(A2)-LEN(B2). A non-zero result confirms hidden characters. Use =CODE(MID(A2,1,1)) on suspicious characters to reveal non-breaking spaces, which show as code 160.

If that did not work, rebuild the formula in a fresh cell rather than editing the old one. Then test with two cells you typed by hand, which rules out paste artefacts entirely.

Frequently Asked Questions

What is the "does not match" operator in Excel?

The angle-bracket pair <>. It sits between two values and returns TRUE when they are different.

Is the not-equal test case-sensitive?

No. <> treats upper and lower case as the same. Use EXACT if case must match exactly.

How do I find values in one list that are missing from another?

Use IF(COUNTIF(range,value)=0,...). A zero count means the value does not appear anywhere in the lookup range.

Why does Excel say two identical-looking values do not match?

Hidden spaces, non-breaking characters or text-versus-number formatting. Clean with TRIM and CLEAN and check cell alignment.

Can I highlight mismatches without a helper column?

Yes, with a conditional formatting rule that uses a formula comparing the two cells. No extra column is needed.

Does the same formula work in Google Sheets?

Yes, though Sheets also accepts !=. Excel requires <>, so using angle brackets keeps the file portable.