The Microsoft Excel TRIM function returns a text value with the lead and trailing spaces removed. You can also use the TRIM function to remove unnecessary space between words in a string. TRIM allows users to quickly remove unnecessary spaces from large data sets, saving you time in the process.
Steps to use the Excel Trim function
Replace the “A2” cell reference with your own.
To eliminate excess spaces from a text string directly, you can use the following formula to replace the example string with your own text.
=TRIM (” This text string contains unnecessary spaces”)
TRIM is intended to remove extra ASCII space characters (decimal value 32) from text strings.
NB: If you really see unnecessary spaces, this is probably caused by a non-breaking space character (Unicode Decimal Value 160) in your text.
TRIM does not support these, so you will need to manually check and remove these characters from your text if you prefer to use them.