The Excel TRIM Function

Related Function:
CLEAN Function

Basic Description

The Excel Trim function takes a supplied text string and removes all spaces, except for single spaces between words or characters.

The syntax of the function is :

TRIM( text )

where the 'text' argument can be supplied to the function either directly, as a text string returned from another formula, or a reference to a cell containing text.

Note that the Trim function differs from the Clean Function in that the Trim function removes additional spaces (represented by the ASCII numeric code 32), while the Clean Function removes the non-printable characters, represented by the ASCII numerics codes 0 to 31.

Trim Function Examples

The example below shows the Trim function used on four different text strings.

Excel Trim Function Examples

In all four of the above cases, the result is the string

"trimmed text"

- with no spaces at the start or end and just one space in the middle.

Further information and examples of the Excel Trim function can be found on the Microsoft Office website.