TRIM vs CLEAN

TRIM removes extra spaces; CLEAN removes invisible characters. With imported data they are almost always used together.

TRIMCLEAN
Leading and trailing spacesRemoves themNo
Double spaces insideLeaves oneNo
Line breaks and control charactersNoRemoves them

Syntax and example

TRIM

=TRIM(text)

=LEN(TRIM(A2))

Removes leading and trailing spaces and leaves a single space between words.

CLEAN

=CLEAN(text)

=TRIM(CLEAN(A2))

Removes the invisible characters (codes 0 to 31) that come along when copying from other systems.

Which one to use?

With text copied from another system, use both: TRIM(CLEAN(A2)).

About Ads

This site uses Google AdSense to display ads. These ads help us keep WebHerramientas completely free. Ads are managed by Google and meet strict security and privacy standards.

Advertising
Loading ad...

Ads help us keep WebHerramientas free for everyone

Practice it

Solve the exercise on the sheet; it is checked instantly. See all lessons · Formula translator

Cleaning imported data: CLEAN and NUMBERVALUE

Data from another system carries invisible characters that TRIM does not remove; CLEAN deletes them. Amounts with dot thousands and comma decimals ("1.234,50") arrive as text: NUMBERVALUE(text, decimal, group) turns them into numbers whatever the regional settings.

Step 1/2

In B2, clean each name: no invisible characters and no extra spaces.

B2
ABCDE
1Imported nameClean nameAmount (text)Amount
2 Ana López1.234,50
3Luis Pérez980,00
4Marta Díaz 12.500,75
5Jorge Ruiz3.040,10
6Sofía Castro15,90
7

Tip: while typing, click a cell or drag across several to insert their reference. F4 anchors the reference with $.

Frequently asked questions

What is the difference between TRIM and CLEAN?
TRIM removes extra spaces; CLEAN removes invisible characters. With imported data they are almost always used together.
When should I use TRIM or CLEAN?
With text copied from another system, use both: TRIM(CLEAN(A2)).