Sometime we may add unwanted spaces in Excel cells, which are not
easy to find out but affect sorting, calculating, or others. This
article will introduce several methods to remove trailing spaces after
text strings of cells in Microsoft Excel.
Kutools for Excel: 200 new features for Excel, make Excel much easy and powerful, increase productivity immediately.
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.
Step 1: Select the range in which you want to remove trailing spaces from cells.
Step 2: Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.
Step 3: Click Insert > Module, and paste the following macro in the Module Window.
Kutools for Excel includes more than 120 handy Excel tools. Free to try with no limitation in 30 days. Get it Now.
Step 1: Select the range in which you want to remove all trailing spaces from cells.
Step 2: Click the Kutools > Text Tools > Remove Spaces. See screenshot:
Step 3: In Remove Spaces dialog box, check the Trailing Spaces option in Spaces Type section. See screenshot:
Step 4: Click OK or Apply. And all the trailing spaces after the text string have been removed. See screenshot:
Kutools for Excel's Remove Spaces
tool makes it possible to delete all kinds of spaces from strings in
cells, including all extra spaces, leading spaces, trailing spaces, or
all spaces. Click to know more...
Recommended Productivity Tools
Office Tab: Bring handy tabs to Excel and other Office software, just like Chrome, Firefox and new Internet Explorer.Kutools for Excel: 200 new features for Excel, make Excel much easy and powerful, increase productivity immediately.
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.
Step 1: Select the range in which you want to remove trailing spaces from cells.
Step 2: Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.
Step 3: Click Insert > Module, and paste the following macro in the Module Window.
Sub NoSpaces()
Dim c As Range
For Each c In Selection.Cells
c = Trim(c)
Next
End Sub
Step 4: Press the F5 key to run this macro. And all of the trailing spaces of the selection will be removed.Dim c As Range
For Each c In Selection.Cells
c = Trim(c)
Next
End Sub
Remove trailing spaces from cells in Excel with Kutools for Excel
Maybe you are not familiar with Microsoft Excel's Macros, and need time to study it. Please do not worry about it. The second method is provided by a third-party add-in, Kutools for Excel. Its Remove Spaces tool can help you remove trailing spaces from cells quickly.Kutools for Excel includes more than 120 handy Excel tools. Free to try with no limitation in 30 days. Get it Now.
Step 1: Select the range in which you want to remove all trailing spaces from cells.
Step 2: Click the Kutools > Text Tools > Remove Spaces. See screenshot:
Step 3: In Remove Spaces dialog box, check the Trailing Spaces option in Spaces Type section. See screenshot:
Step 4: Click OK or Apply. And all the trailing spaces after the text string have been removed. See screenshot: