Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

How to remove trailing spaces from cells in Microsoft Excel?

Supposing you got an Excel worksheet from others, and you found that there are unwanted spaces at the end of the cells. And these trailing spaces are not easy to find out and affecting cell sorting, calculating, or other operations. This article will introduce several methods to remove trailing spaces from cells in Microsoft Excel as below screenshot shown.

Remove trailing spaces from cells in Excel with VBA

Remove trailing spaces from cells in Excel with Kutools for Excel


Quickly remove spaces (leading/trailing/excess spaces) from selected cells:

With the Remove Spaces utility of Kutols for Excel, you can quickly remove specific spaces such as leading spaces, trailing spaces, or excess spaces from selected cells at once in Excel. See screenshot:

Kutools for Excel: with more than 200 handy Excel add-ins, free to try with no limitation in 60 days. Download and free trial Now!

Excel Productivity Tools

Office Tab: Bring powerful tabs to Office (include Excel), just like Chrome, Safari, Firefox and Internet Explorer. Save you half the time, and reduce thousands of mouse clicks for you. 30-day Unlimited Free Trial

Kutools for Excel: Save 70% of your time and solve 80% Excel problems for you. 300+ advanced features designed for 1500+ work scenario, make Excel much easy and increase productivity immediately.60-day Unlimited Free Trial


Remove trailing spaces from cells in Excel with VBA


Using the Trim function is easy to remove the trailing space in one cell, but time-consuming to remove trailing spaces in many cells. Here provides a macro to remove all trailing spaces of all cells in a selection.

1: Select the range you want to remove trailing spaces from cells.

2. Press the ALT + F11 keys to open the Microsoft Visual Basic for Applications window.

3. Click Insert > Module, and paste the following macro in the Module Window.

VBA code: Remove all trailing spaces from selected cells in Excel

Sub NoSpaces()
'Update by Extendoffice 20180613
Dim c As Range
For Each c In Selection.Cells
c = Trim(c)
Next
End Sub

4. Press the F5 key to run this macro. Then all trailing spaces are removed from cells of selected range immediately.


Remove trailing spaces from cells in Excel with Kutools for Excel

This section is going to introduce a handy addin - Kutools for Excel. Its Remove Spaces tool can help you remove all trailing spaces from cells quickly. Please do as follows

Kutools for Excel includes more than 300 handy Excel tools. Free to try with no limitation in 30 days. Get it Now.

1. Select the range you want to remove all trailing spaces from cells, then click Kutools > Text > Remove Spaces. See screenshot:

2. In the Remove Spaces dialog box, check the Trailing Spaces option in Spaces Type section and then click the OK button. See screenshot:

Then you can see all trailing spaces have been removed from selected cells immediately. See screenshot:

Tip.If you want to have a free trial of this utility, please go to download the software freely first, and then go to apply the operation according above steps.


Demo: Remove trailing spaces from selected cells with Kutools for Excel

Kutools for Excel includes more than 300 handy Excel tools. Free to try with no limitation in 60 days. Download the free trial now!


Related articles:


Excel Productivity Tools

Ribbon of Excel (with Kutools for Excel installed)

300+ Advanced Features Increase Your Productivity by 70%, and Help You To Stand Out From Crowd!

Would you like to complete your daily work quickly and perfectly? Kutools For Excel brings 300+ cool and powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) for 1500+ work scenarios, helps you solve 80% Excel problems.

  •  Deal with all complicated tasks in seconds, help to enhance your work ability, get success from the fierce competition, and never worry about being fired.
  •  Save a lot of work time, leave much time for you to love and care the family and enjoy a comfortable life now.
  •  Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands, and give you a healthy body.
  •  Become an Excel expert in 3 minutes, and get admiring glance from your colleagues or friends.
  •  No longer need to remember any painful formulas and VBA codes, have a relaxing and pleasant mind, give you a thrill you've never had before.
  •  Spend only $39, but worth than $4000 training of others. Being used by 110,000 elites and 300+ well-known companies.
  •  60-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years. Buy once, use forever.
  •  Change the way you work now, and give you a better life immediately!

Office Tab Brings Efficient And Handy Tabs to Office (include Excel), Just Like Chrome, Firefox, And New IE

  • Increases your productivity by 50% when viewing and editing multiple documents.
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • Open and create documents in new tabs of same window, rather than in new windows.
  • Help you work faster and easily stand out from the crowd! One second to switch between dozens of open documents!
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Charles · 3 years ago
    Thanks for the macro to trim trailing spaces - easy, effective, and awesome.