Related Function:

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



Note: 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.


Argument Description
text The text from which you want spaces removed

Note: 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.


  A B C D
1 Text Formula Result Notes
2      trimmed text =TRIM(A2) trimmed text Removes spaces from beginning of text string
3   =TRIM(“trimmed text    “) trimmed text Removes spaces from end of text string
4   =TRIM(“trimmed     text”) trimmed text Removes extra spaces from middle of text string
5   =TRIM(”  trimmed   text  “) trimmed text Removes extra spaces from beginning, middle, and end of text string