Skip to main content

Kutools for Office — One Suite. Five Tools. Get More Done.

How to remove leading and trailing spaces in Excel?

Author Zhoumandy Last modified

In the world of data management, tidiness is key. Yet, pesky leading and trailing spaces can often sneak into your Excel sheets, causing discrepancies and headaches. Fortunately, Excel offers handy tools to swiftly eliminate these unnecessary spaces, ensuring your data stays clean and accurate. In this article, we'll explore two efficient methods to remove leading and trailing spaces in Excel.

A screenshot of an Excel dataset with leading and trailing spaces for cleaning

Using the TRIM function in Excel to remove leading and trailing spaces

Quickly remove all leading and trailing spaces with Kutools for Excel


Using the TRIM function in Excel to remove leading and trailing spaces

Here is the generic formula of TRIM function:

=TRIM (text)
Step 1: Input the TRIM formula

In cell C2, apply the following formula, then press the Enter button.

=TRIM(A2)
Step 2: Copy the formula down to below cells to get all results

A screenshot showing the use of the TRIM function in Excel to remove leading and trailing spaces

Note: The TRIM function does not remove all types of space characters.

Quickly remove all leading and trailing spaces with Kutools for Excel

Compare to the TRIM function, the "Removing Spaces" utility in Kutools for Excel provides a more flexible way to remove all leading and trailing spaces in Excel. You can directly remove the space in the cell without moving them into other cells. More importantly, you can also remove other types of spaces, such as excess spaces or all spaces within cells.

Kutools for Excel offers over 300 advanced features to streamline complex tasks, boosting creativity and efficiency. Itegarate with AI capabilities, Kutools automates tasks with precision, making data management effortless. Detailed information of Kutools for Excel...         Free trial...

1. Select the cells that you want to modify. You can select some columns, rows or the entire worksheet.

A screenshot showing the selection of Excel cells before using Kutools' Remove Spaces feature

2. Click "Kutools" > "Text" > "Remove Spaces", and check the "Leading & Trailing spaces" option in the popup "Remove Spaces" dialog. Click OK.

A screenshot of the Remove Spaces dialog box with options selected

Now, you will see that all leading and trailing spaces have been removed instantly!

A screenshot of cleaned data in Excel after removing leading and trailing spaces using Kutools

Tip: To use this feature, you should install Kutools for Excel first, please click here to download Kutools for Excel now.