Related Tutorial: When the TRIM Function Doesn't Work
Remove Extra Spaces with the TRIM Function
When text data is imported or copied into an Excel spreadsheet extra spaces can sometimes be included along with the text data.
The TRIM Function's Syntax and Arguments
The syntax for the TRIM function is:
= TRIM ( Text )
Text - the data you want to remove spaces from. Although the argument can contain the actual data enclosed in quotation marks, it can also be a cell reference to the location of the text data in the worksheet.
In this tutorial we will remove extra spaces from data by using the data's cell reference as the function's argument.
Example: Remove Extra Spaces with the TRIM Function
As can be seen in the image above, this example will remove extra spaces from between words entered into an Excel worksheet.
- Enter the following text into cell D1 (be sure to include extra spaces between the words):
Remove Extra Spaces in Excel
- Click on cell D3 in the spreadsheet - this is where the function will be located.
- Click on the Formulas tab of the ribbon menu.
- Choose Text from the ribbon to open the function drop down list.
- Click on TRIM in the list to bring up the function's dialog box.
- In the dialog box, click on the Text line.
- Click on cell D1 in the spreadsheet.
- Click OK.
- The line of text Remove Extra Spaces in Excel should appear in cell D3 but with only one space between each word.
- When you click on cell D3 the complete function = TRIM ( D1 ) appears in the formula bar above the worksheet.
If the TRIM Function Doesn't Work
On a computer, a space between words is not a blank area but a character, and, believe it or not, there is more than one type of space character.
The TRIM function will not remove all space characters. In particular one commonly used space character that TRIM will not remove is the non-breaking space used in web pages ( ).
If you have web page data with extra spaces, try this tutorial on a TRIM function alternative that may fix the problem.