SpreadsheetFormulas
beginnerTRIMSUBSTITUTE

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.

Quick formula
=TRIM(A2)
Sample input
1Raw
2 Ana Torres
3Ben Okafor
4 Cara Lim
Result
1RawCleaned
2 Ana Torres Ana Torres
3Ben OkaforBen Okafor
4 Cara LimCara Lim

Excel & Google Sheets

=TRIM(A2)

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.

TRIM(A2)
Strips edge spaces and collapses internal runs of spaces to one.

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

  • TRIM "doesn't work" on data copied from the web.

    That's usually a non-breaking space, which TRIM won't remove. Use =TRIM(SUBSTITUTE(A2,CHAR(160)," ")).

  • Trimming in place and deleting the original column too soon.

    The TRIM column still references the original. Copy the trimmed column and Paste Special → Values before deleting the source.

Did this formula help?

Engine-verified against the sample data aboveLast reviewed 2026-07-08