TRIM Function
Removes extra spaces, leaving single spaces between words.
Category
Text
Available in
All versions, Microsoft 365
Returns
Text
Overview
TRIM removes spaces from the start and end of text and squeezes runs of spaces between words down to one.
Stray spaces are invisible but break lookups and duplicates checks — “Ana ” doesn't match “Ana”. TRIM is the first thing to try on imported data.
Syntax
Arguments
| Argument | Required? | What it does |
|---|---|---|
| text | Yes | The text or cell to clean. |
Examples
Example 1 — Cleaning an import
Names from Northstar's old system came padded with spaces. LEN shows the difference.
| A | B | |
|---|---|---|
| 1 | Imported name | Clean length |
| 2 | Ana Lopez | 9 |
| 3 | Ben Cho | 7 |
| 4 | Cara Singh | 10 |
=TRIM(A2) returns “Ana Lopez”, and its length drops from 14 to 9.
Example 2 — Fixing a lookup that won't match
Clean the lookup value inside the formula.
Common mistakes
- Non-breaking spaces survive. Text copied from websites often contains character 160, which TRIM ignores. Use =TRIM(SUBSTITUTE(A2, CHAR(160), " ")).
Notes
- TRIM doesn't remove line breaks — that's CLEAN's job.
- Related functions: CLEAN, SUBSTITUTE, LEN.

Author
Kyle Stott
Certified Microsoft Excel Expert
Kyle has worked professionally with Microsoft Excel for over a decade and has consulted on and taught Excel best practices to over 400 companies across 30+ countries.