When text data is imported or copied into an Excel spreadsheet extra spaces can sometimes be included along with the words.
Excel's TRIM function, one of Excel's text functions, can be used to remove these unwanted spaces.
The syntax for the TRIM function is:
= TRIM ( Text )
Text - the text you want to change. This can be a cell reference to where the text is stored.
Example Using Excel's TRIM Function:
Note: For help with this example, see the image to the right.
- Enter the following text into cell D1:
Today's oil price is : (be sure to include extra spaces between the words)
- 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 Today's oil price is: should appear in cell D3 but without the extra spaces between the words.
- When you click on cell D3 the complete function = TRIM ( D1 ) appears in the formula bar above the worksheet.
Related Articles


