The Excel TRIM Function
Related Function:CLEAN Function
If supplied Excel Trim function removes extra spaces (i.e. all spaces except for single spaces between words or characters) from a supplied text string.
The syntax of the function is:
TRIM( text )
where the text argument is the text string that you want to remove the extra spaces from.
Trim vs. Clean Function
Note that the Trim function is similar to the Excel Clean Function
. The two functions differ 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 spreadsheet below shows the Trim function used on four different text strings.
In all four of the above cases, the result is the string
- 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.