The Microsoft Excel TRIM function returns a text value with the leading and trailing spaces removed. You can also use the TRIM function to remove unnecessary spaces between words in a string. With TRIM, users can quickly remove unnecessary space from large amounts of data, saving you time.
Steps to use the Excel trim feature
Replace the cell reference “A2” with your own.
To remove excess spaces directly from a text string, you can use the following formula to replace the sample string with your own text.
= TRIM (“This text string contains unnecessary spaces”)
TRIM is designed to remove extra ASCII spaces (decimal 32) from text strings.
NB: If you see really unnecessary spaces, it is probably caused by a non-breaking space (Unicode decimal value 160) in your text.
TRIM does not support these, so you will have to manually check these characters and remove them from your text if you prefer.