TRIM
Remove extra spaces from text with Excel's TRIM function, leaving single spaces between words.
Spreadsheet editor
Spreadsheet editor
Syntax
=TRIM(text)
Returns: Text Arguments
| Argument | Required | Description |
|---|---|---|
| text | Yes | The text or cell reference containing the text you want to clean up. |
About
Use TRIM whenever you paste or import data and the spacing looks off. Names copied from a website, codes from another system, or values typed by hand often carry hidden spaces that break lookups, sorting, and joins. Cleaning the text first can mean VLOOKUP and XLOOKUP actually find their matches.
Keep in mind TRIM only handles the standard space character. It will not touch non-printable characters or the non-breaking spaces that often come from web pages. For those, pair it with CLEAN, or use SUBSTITUTE when you need to remove every space, including the ones between words.
Exercises using TRIM
Fixing text to be exact
BeginnerOpen exercise
Clean imported data with PROPER and TRIM
BeginnerFix inconsistent capitalization in names and remove extra spaces from imported notes.
Open exerciseClean and standardize names
AdvancedStandardize company names (remove Inc/LLC/Corp, handle "The", title case).
Open exerciseComplex text parsing
AdvancedParse inconsistently formatted addresses into separate columns (street, city, state, zip).
Open exerciseExamples
Count the hidden spaces in your data
Spreadsheet editor
Remove every space, not just the extras
Spreadsheet editor
Watch out for
Non-breaking spaces stay put
Text copied from websites often contains non-breaking spaces (character 160). TRIM only removes the standard space (character 32), so the value can still look untidy and lookups still fail.
→ Convert the non-breaking spaces first with SUBSTITUTE, for example =TRIM(SUBSTITUTE(A2,CHAR(160)," ")), or run CLEAN alongside TRIM.
Expecting it to remove all spaces
TRIM keeps single spaces between words, so it will not turn "New York" into "NewYork". People sometimes reach for it to strip every space.
→ To remove every space, use SUBSTITUTE instead, such as =SUBSTITUTE(A2," ","").
The original cell still has spaces
TRIM returns a cleaned copy in a new cell. The source cell keeps its extra spaces, which can confuse later steps that still point at the original.
→ Copy the TRIM results, then paste them back over the original data as values once you are happy with the output.