Excel TRIM Function
The Excel TRIM function removes all extra spaces from text string and only keeps single spaces between words.
The text with extra spaces removed
- The TRIM function can only remove the 7-bit ASCII space character (value 32) from text;
- The TRIM function can’t remove the non-breaking space character (value 160) which is commonly used in Web pages as the HTML entity;
Example 1: Remove extra spaces from text and only keep single spaces between words
If you want to remove spaces such as leading, trailing and extra spaces from a cell, please do as follows.
Select a blank cell, copy the below formula into it to get the result. Keep selecting the result cell, drag the Fill Handle to apply the formula to other cells.
Example 2: Remove extra spaces and line breaks from text
The TRIM function can’t remove the non-breaking space character from cell. If you want to remove both the extra spaces and line breaks from text at the same time. Please apply the below formula.
Select a blank cell, copy the below formula into it to get the result. You can see extra spaces and non-breaking character are removed at once.