This page isn't translated yet, so its text is in English. Function names and formulas are shown in your Excel language.
Excel function · Changing text
TRIM
Removes extra spaces from a text.
What it does
TRIM removes spaces at the start and end of a text and shrinks any run of spaces between words to one. Data pasted from other systems often has extra spaces that break lookups and comparisons.
Syntax
=TRIM(text)Arguments in square brackets are optional, and … means you can add more of the same. In this Excel language, arguments are separated by ,
Arguments
- text
- The text to clean, usually a cell.
Example
An imported name has spaces before, between and after the words. How do you clean it?
| A | B | |
|---|---|---|
| 1 | As entered | Cleaned |
| 2 | Ana Ruiz | Ana Ruiz |
The formula in B2:
=TRIM(A2)Result: Ana Ruiz
The two leading spaces and the trailing one are removed, and the three spaces between the words become one, giving Ana Ruiz.
Common mistakes
- Expecting it to remove the non-breaking spaces some web pages use. Replace those with
SUBSTITUTEfirst. - Cleaning only one side of a lookup. If the lookup fails because of spaces, trim both the value and the list.
In other Excel languages
Excel translates function names, and in some languages the argument separator too. Type the name your Excel shows.
| Excel language | Function name | Separator |
|---|---|---|
| English | TRIM | , |
| Deutsch | GLÄTTEN | ; |
| Français | SUPPRESPACE | ; |
| Español (España) | ESPACIOS | ; |
| Español (México) | ESPACIOS | , |
| 日本語 | TRIM | , |
| 한국어 | TRIM | , |
| 繁體中文 | TRIM | , |
| ไทย | TRIM | , |
| ខ្មែរ | TRIM | , |
| Tiếng Việt | TRIM | ; |