| Syntax |
| =TRIM(text) |
| Purpose / Description |
| Returns a copy of the text string from which extraneous spaces — any leading or trailing space characters and duplicate space characters within the string — have been removed. |
| Arguments |
| Name |
Type |
Description |
| text |
text string |
A constant, reference or nested expression that provides the text string from which the extraneous spaces are to be removed. If the character count of this argument exceeds 32,767, the text string is truncated. |
| Return Values |
| Type |
Specific Value |
Description |
| text string |
|
The trimmed string from which extraneous spaces have been removed. |
| error |
|
Any errors referenced by arguments are returned due to propagation of error values. |
| Notes / Comments / Advice / Warnings |
| Comment: |
This function does not remove non-breaking spaces, which are quite common in data from Word, web and PDF documents for formatting purposes. In this case, a SUBSTITUTE function would be required to replace the non-breaking spaces (character code 160) with ordinary spaces (character code 32) before passing to the TRIM function. Examples of this are demonstrated in our Wiki articles. |
| Examples: |
Open / download sample workbook: TRIM.xlsx |
| |