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!

Office Tab Enable Tabbed Editing and Browsing in Office, and Make Your Work Much Easier...
Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%
  • Reuse Anything: Add the most used or complex formulas, charts and anything else to your favorites, and quickly reuse them in the future.
  • More than 20 text features: Extract Number from Text String; Extract or Remove Part of Texts; Convert Numbers and Currencies to English Words.
  • Merge Tools: Multiple Workbooks and Sheets into One; Merge Multiple Cells/Rows/Columns Without Losing Data; Merge Duplicate Rows and Sum.
  • Split Tools: Split Data into Multiple Sheets Based on Value; One Workbook to Multiple Excel, PDF or CSV Files; One Column to Multiple Columns.
  • Paste Skipping Hidden/Filtered Rows; Count And Sum by Background Color; Send Personalized Emails to Multiple Recipients in Bulk.
  • Super Filter: Create advanced filter schemes and apply to any sheets; Sort by week, day, frequency and more; Filter by bold, formulas, comment...
  • More than 300 powerful features; Works with Office 2007-2019 and 365; Supports all languages; Easy deploying in your enterprise or organization.

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:


Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial.
kte tab 201905

Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
officetab bottom
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.
    Mario · 1 years ago
    THANK YOU SO MUCH! I was going crazy doing a MS Word Mail merge from Excel data and couldn't figure out why there was extra space in the fields. MANY THANKS!
  • To post as a guest, your comment is unpublished.
    Sakshi Sharma · 2 years ago
    Remove all white spaces after last character.
    Ex. "CABLE AS " it should become "CABLE AS"
    ("" not there in the cell)
  • To post as a guest, your comment is unpublished.
    umar jaan · 2 years ago
    You Made my life, feeling excited thanks for this micro code. SUUUUUUUUUUUUUUPPPERRRRR
  • To post as a guest, your comment is unpublished.
    Brian · 2 years ago
    You might mention that you shouldn't select the entire worksheet as the range. It takes a very, very long time to process that many cells.
  • To post as a guest, your comment is unpublished.
    Sam · 2 years ago
    Awesome! Thanks! Saved a lot of time!!
  • To post as a guest, your comment is unpublished.
    Patrick Baldwin · 3 years ago
    WOW! Couldn't have been easier - thank you so much for the help!
  • To post as a guest, your comment is unpublished.
    Syed · 3 years ago
    Very good. Saved me a lot of time, thanks!
  • To post as a guest, your comment is unpublished.
    Paul D · 3 years ago
    I solved it by copying the first formula in my 32 options I wanted to keep a part of the table, and pasted on the other 31 parts and the job was done.
  • To post as a guest, your comment is unpublished.
    Vikash Sharma · 3 years ago
    Hello Frnds,
    Need help to resolve a problem.

    Problem:
    I have data in one single cell like as below:

    REQ-0001

    REQ-00044

    REQ-343543

    (data is in single cell and having space in between). I want to just remove this breakline space and get the data in one single cell only as below:

    REQ-0001
    REQ-00044
    REQ-343543

    Thanks in advance.
  • To post as a guest, your comment is unpublished.
    !MikeG! · 4 years ago
    Great article. Is there a way to tie the VBA code to a button?

    In order for the user to quickly hit and have the trailing spaces removed from a specific column.
  • To post as a guest, your comment is unpublished.
    Charles · 4 years ago
    Thanks for the macro to trim trailing spaces - easy, effective, and awesome.