Trim() function

The Excel TRIM function strips extra spaces from text, leaving only a single space between words and no space characters at the start or end of the text.

Syntax

The syntax for the TRIM function in Microsoft Excel is:

TRIM( text )

Parameters or Arguments

text

The text value to remove the leading and trailing spaces from.

Trim Function Examples

The following spreadsheet shows the Trim function applied to four different text strings.

Formula:

Result:

In all four of the above cases, the result is the string “Sample Text”

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

Notes

  • TRIM strips extra spaces from text, leaving only single spaces between words and no space characters at the start or end of the text.
  • TRIM is useful when cleaning up text that has come from other applications or environments.
  • TRIM only removes the ASCII space character (32) from text.
  • Unicode text often contains a non-breaking space character (160) that appears in web pages as an HTML entity. This will not be removed with TRIM.
  • The CLEAN function strips the first 32 non-printing characters (ASCII values 0 through 31) from text.

Excel Function Home

Text Functions