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 nowHow 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
Examples
Clean the first name
=TRIM(A2)Abebe KebedeSpaces at both ends go.
Fix repeated spaces
=TRIM(A3)Liya TesfayeInner gaps shrink to a single space.
Measure the clean result
=LEN(TRIM(A4))3Compare with LEN(A4) to detect hidden spaces.
Your turn
Clean the name in A5. Type your formula in D2.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Name | Age | ||
| 2 | Abebe Kebede | 34 | ||
| 3 | Liya Tesfaye | 29 | ||
| 4 | Sam | 41 | ||
| 5 | Hana Bekele | 25 | ||
| 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.
Excelio