Excel Formula TRIM
This function removes extra (or padded) spaces that infect your data as a result of user error, downloading data from an external source such as the Internet, or importing data from another computer system. And you don’t have to “tell Excel” where the spaces are located in the string of text in each cell; it recognizes the extra spaces and removes them. Note; however, that it will not remove a space in the middle of a word. The syntax is simple: =TRIM(cell address).
1. Enter some data in column A. Add some spaces before, after, and in the middle of multiple words, then enter the following formula in cell A4: =TRIM(A4).
2. Copy the formula down. It’s that easy!
NOTE: There is one case where this function does not work, and that’s with a non-breaking space character used in webpages. The decimal value is 160, and the HTML code is  . You can remove this character using a combination of TRIM, CLEAN, and SUBSTITUTE.