Stop Comparing Cells Manually — Try This Instead

Why does your report show ‘Match’ when it shouldn’t? Why does =A1=B1 return FALSE even though the values look identical? Why does copying the same formula down Column C give inconsistent results?

The answer is almost always hidden whitespace, invisible characters, or mismatched data types — not your formula. Excel doesn’t care what something *looks* like. It cares what it *is*.

The Problem

You’re auditing vendor payments. Column A holds invoice IDs from your ERP system. Column B holds the same IDs entered manually by finance staff. You need to flag mismatches before payment processing — but scanning 472 rows by eye isn’t safe or scalable.

RowERP ID (A)Finance ID (B)Manual Check
2INV-2024-0876INV-2024-0876
3INV-2024-0877INV-2024-0877 ✗ (trailing space)
4INV-2024-0878inv-2024-0878✗ (case difference)
5INV-2024-0879INV-2024-0879
6INV-2024-0880INV-2024-0880 ✗ (non-breaking space)
7INV-2024-0881#N/A✗ (error)

That’s 3 mismatches in 6 rows — all invisible to the naked eye. Your brain sees ‘same’. Excel sees different character codes.

The Solution

Use this single formula in C2 and drag down:

=EXACT(TRIM(CLEAN(A2)),TRIM(CLEAN(B2)))

It works because:

  • CLEAN() removes non-printable characters (like ASCII 160 — the sneaky non-breaking space in row 6)
  • TRIM() strips leading/trailing spaces (row 3)
  • EXACT() compares case-sensitively — no surprises (row 4)

Here’s what happens step-by-step:

StepActionResultShortcut
1In C2, type =EXACT(TRIM(CLEAN(A2)),TRIM(CLEAN(B2)))FALSE (row 3)
2Press Ctrl+Enter to keep focus in C2Formula stays activeCtrl+Enter
3Select C2, then drag fill handle down to C7All 6 comparisons calculatedClick + drag
4Select C2:C7 → Home tab → Conditional Formatting → Highlight Cell Rules → Equal To → TRUE → Green fillMatches glow green; mismatches stay plainAlt+H+L+G
RowERP ID (A)Finance ID (B)=EXACT(TRIM(CLEAN(A2)),TRIM(CLEAN(B2)))
2INV-2024-0876INV-2024-0876TRUE
3INV-2024-0877INV-2024-0877 TRUE
4INV-2024-0878inv-2024-0878FALSE
5INV-2024-0879INV-2024-0879TRUE
6INV-2024-0880INV-2024-0880 TRUE
7INV-2024-0881#N/A#N/A

Notice row 7 returns #N/A — not FALSE. That’s correct. You can’t compare an error to text. Handle that separately (see next section).

Going Further

Real work isn’t just exact matches.

Partial match inside a longer string? Use =ISNUMBER(SEARCH(A2,B2)) — but know this is case-insensitive and fails if A2 is blank. Wrap it: =IF(A2="","",ISNUMBER(SEARCH(A2,B2))).

Match ignoring case but still catching whitespace? Skip EXACT. Use =TRIM(CLEAN(A2))=TRIM(CLEAN(B2)). Simpler. Faster. Less strict.

What if one cell is numeric and the other is text? Force both to text first: =TEXT(A2,"@")=TEXT(B2,"@"). Works for dates, numbers, and strings alike.

Surprising tip: EXACT() treats empty cells and zero-length strings (“”) as identical. But =""=A2 does not — it returns FALSE if A2 contains only spaces. Always use TRIM(CLEAN()) first if blanks are possible.

Need to highlight mismatches across two entire ranges? Select B2:B100 → Home → Conditional Formatting → New Rule → Use a formula → =EXACT(TRIM(CLEAN($A2)),$B2)=FALSE → Format red. Done.

When NOT to Use This

This approach fails silently in three cases:

  • Dates formatted differently: 45231 (serial number) vs “2023-10-15” (text). Convert both to date serials first: =EXACT(TEXT(A2,"yyyymmdd"),TEXT(B2,"yyyymmdd"))
  • Numbers with custom formatting: $45,200.00 vs 45200. Use VALUE() or double-unary: =EXACT(--A2,--B2) — but only if both are truly numeric.
  • Cells containing formulas returning "": =IF(A1>100,"OK","") looks empty but isn’t. Test with LEN(TRIM(CLEAN(A2)))=0, not A2="".

If your data includes hyperlinks, merged cells, or array formulas — stop. Clean the source first. No formula fixes dirty structure.

Keyboard Shortcuts

ActionWindows ShortcutMac Shortcut
Open Conditional FormattingAlt+H+LControl+Option+Command+T
Insert Function DialogShift+F3Shift+Command+A
Edit Cell FormulaF2Control+U
Fill Down (from active cell)Ctrl+DCommand+D
Toggle Formula ViewCtrl+` (backtick)Command+`
Sarah Mitchell

Sarah Mitchell

Sarah has 12 years of experience covering Microsoft 365 productivity tools and enterprise software workflows. She specializes in Excel automation and SharePoint integration.