Skip to main content

TRIM function


The CLEAN Function removes all spaces from text except for single spaces between words.

Use TRIM on text that you have received from another application that may have irregular spacing.




Text Required. The text from which you want spaces removed.


The TRIM function was designed to trim the 7-bit ASCII space character (value 32) from text. In the Unicode character set, there is an additional space character called the non-breaking space character that has a decimal value of 160. This character is commonly used in Web pages as the HTML entity,  . By itself, the TRIM function does not remove this non-breaking space character.

If you want to remove non-printable characters, please use CLEAN function.


The example may be easier to understand if you copy the example data (include header) in the following table, and paste it in cell A1 of a new Excel worksheet. If you need to, you can adjust the column widths to see all the data.

Formula Result Description
=TRIM(" Microsoft Excel ") Microsoft Excel Removes all spaces from text except for single spaces between words.
=TRIM(" Excel ") Excel Removes leading and trailing spaces from the text.
=TRIM(" Office") Office Removes leading spaces from the text.
=TRIM("Excel ") Excel Removes trailing spaces from the text.

Leave a comment

Your email address will not be published. Required fields are marked *

Format your code: <pre><code class="language-vba">place your code here</code></pre>