Remove extra spaces from text
=TRIM(text)
| Parameter | Description |
|---|---|
text |
The text from which to remove extra space. |
The TRIM function strips extra spaces from text, leaving only a single space between words, and removing any leading or trailing space. For example:
=TRIM(" A stitch in time. ") // returns "A stitch in time."
The TRIM function can be used together with the CLEAN function to remove extra space and strip out other non-printing characters:
=TRIM(CLEAN(A1)) // trim and clean
TRIM often appears in other more advanced text formulas. For example, the formula below will count the number of words in cell A1:
LEN(TRIM(A1))-LEN(SUBSTITUTE(A1," ",""))+1