< Go Back

Remove leading and trailing spaces from text

Those working with a large amount of data often face the problem of having to deal with spaces in the text. Microsoft Excel has some excellent features to deal with spaces. The TRIM function in Excel removes unwanted spaces from text. In this tutorial, you will learn how to remove unnecessary spaces from text with the TRIM function in Excel.

How to Excel Remove Leading and Trailing Spaces from Text in Excel

You can use the TRIM function to remove leading and trailing spaces from text. The TRIM function is very simple to use. It only takes one argument, the text to perform the operations on. It removes all leading and trailing spaces from the text. The generic formula looks like:


TRIM is a text function that is fully automatic. It removes the spaces from the front and back of the text you provide and also removes multiple spaces between two words. You just need to provide the cell reference, and TRIM does the rest of the work.


The following example contains some part of a student information data set. Column A has the student names. However, the names have a lot of leading and trailing spaces. To remove these with the TRIM function:

  • Go to cell B2. Select it by clicking with your mouse.
  • Assign the formula,=TRIM(A2) to cell B2.
  • Press enter to apply the formula to cell B2.
  • Drag the fill handle from cell B2 to B7 to copy the formula to the rest of the cells in column B.

    1. Figure 1 of Removing Leading & Trailing Spaces from Text with the TRIM function

This will help the TRIM function to remove the leading, trailing and in-between spaces from the names in column A.

The TRIM function is one of the Excel text functions that help remove spaces. Using the TRIM function, you can remove leading and trailing spaces from the text in the simplest way.


Our customers love us!
“The expert was absolutely amazing and stuck with me the whole way through. They were polite, patient, seemed to want to genuinely help me and provided a solution that I would never have managed otherwise. I could not be more thankful for their support and solution. Thank you!” - - Chris T, in California

Leave a Comment