Skip to content

Lessons in your language are coming soon. Formulas already work in your Excel language.

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?

AB
1As enteredCleaned
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 SUBSTITUTE first.
  • 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 languageFunction nameSeparator
EnglishTRIM,
DeutschGLÄTTEN;
FrançaisSUPPRESPACE;
Español (España)ESPACIOS;
Español (México)ESPACIOS,
日本語TRIM,
한국어TRIM,
繁體中文TRIM,
ไทยTRIM,
ខ្មែរTRIM,
Tiếng ViệtTRIM;

Practise it

More from this module

All functions