Strip leading, trailing, and duplicate spaces from text with TRIM.
Copy this formula
=TRIM(A2)TRIM removes spaces before, after, and any extra spaces between words (collapsing them to single spaces). It's the first fix for lookup mismatches caused by stray spaces.
=TRIM(" hello world ")→hello worldCollapses messy spacing to a clean single-spaced string.
Also remove non-breaking spaces
=TRIM(SUBSTITUTE(A2, CHAR(160), " "))Web-pasted text often hides CHAR(160) spaces that TRIM alone misses.
It's likely a non-breaking space (CHAR 160) from a web copy. Use the SUBSTITUTE variant above.
Need a formula for your own data?
Describe what you want in plain language and let ExcelGPT write, explain, and verify the formula — free to start, no plugin.