Remove Extra Spaces from Text
Values that look identical refuse to match — because "Ana Torres " has an invisible trailing space. Imported and copy-pasted data is full of them.
Excel & Google Sheets
This formula works in both Excel and Google Sheets.
How it works
TRIM removes all spaces from the start and end of the text, and collapses any run of multiple spaces in the middle down to a single space. " Ana Torres " becomes "Ana Torres". It's the standard first step when cleaning imported data, and the most common cure for lookups that mysteriously return #N/A on values that look right. One caveat: web data often contains non-breaking spaces (character 160), which TRIM ignores — see the mistakes below.
When to use it
Run TRIM over any pasted or imported text before using it in lookups, comparisons, or deduplication. Add a clean column, TRIM everything, then paste it back as values.
Common mistakes
Did this formula help?
Engine-verified against the sample data aboveLast reviewed 2026-07-08