Excel TRIM

TRIM removes spaces from the start and end of text and shrinks repeated spaces to one.

Two customer records look identical but a lookup says they don't match. A stray space at the end is the usual culprit, and it's invisible. TRIM is often the first step in cleaning anything exported from another system.

Practice it now

How to write it

=TRIM(text)
text
The text to clean.

Watch it work

D2fx 
ABCDE
1NameAge
2Abebe Kebede34
3Liya Tesfaye29
4Sam41
5Hana Bekele25
6
1

Spaces at both ends go.

Examples

Clean the first name

=TRIM(A2)Abebe Kebede

Spaces at both ends go.

Fix repeated spaces

=TRIM(A3)Liya Tesfaye

Inner gaps shrink to a single space.

Measure the clean result

=LEN(TRIM(A4))3

Compare with LEN(A4) to detect hidden spaces.

Your turn

Clean the name in A5. Type your formula in D2.

ABCD
1NameAge
2 Abebe Kebede 34
3Liya Tesfaye29
4Sam 41
5 Hana Bekele25
6

Common mistakes

Spaces remain.

Web data often has non-breaking spaces. Replace CHAR(160) with SUBSTITUTE first.

Forgetting to replace the originals.

Paste the results as values over the source if needed.

Good to know

  • TRIM the lookup value and source when a match fails.
  • Pair with PROPER to tidy names.
  • TRIM or CLEAN? TRIM removes spaces. CLEAN removes invisible control characters.