Remove irregular spacing from either end of or within a text string.
TRIM(text)
Remove irregular spacing from either end of or within a text string using either defined values (e.g. "string") or cell references (e.g. C3).
TRIM syntax requires just the defined value or cell reference to be trimmed.
TRIM with a text string.
In the examples below, the TRIM function is used to remove irregular spacing before, within or after the defined text string " North America " or cell reference to "Ottawa ".
Use the TRIM function to remove irregular spacing from either end of or within a text string.

Syntax
The TRIM function consists of 1 argument:
- text. Required. The string from which to trim the irregular spaces.
Try it now!
Enter your formula into the grey cells.
Scope
TRIM() can be applied to cell references, text or numbers.
|
=TRIM(C3) |
|
=TRIM(" South America ") || returns South America. |
|
=TRIM( 123456.78 )*1 || returns the number 123456.78. |
Caveats
- The TRIM() function was designed to trim a 7-bit ASCII space character (value 32) from a text string.
- TRIM() will not remove nonbreaking space characters from the Unicode character set (value 160) such as used in HTML.
Related Functions
- The CLEAN() function can help remove the first 32 nonprinting characters in the 7-bit ASCII code (values 0 through 31) from text.
- The SUBSTITUTE() function can be used to replace higher value Unicode characters (values 127, 129, 141, 143, 157 and 160) with the 7-bit ASCII characters for which the TRIM() function was designed.
Functions Category