How to Remove Extra Spaces Between Words in Cells in Excel?


Have you ever had to read and understand data from a disorganised spreadsheet with numerous spaces between words? Don't worry; we'll show you how to remove those excess spaces and make your Excel data appear tidy and organised using a quick and easy approach. This article explains how to eliminate excessive spaces between words in Excel cells. Whether your dataset is little or huge, Excel provides a number of methods to assist you quickly and precisely remove those extra spaces.

Remove Extra Spaces Between Words in Cells

Here, we will first create a VBA module and then run it to complete the task. So let us see a simple process to learn how you can remove extra spaces between words in cells in Excel.

Step 1

Consider an Excel workbook where you have a list of strings with large spaces, similar to the below image.

First, right-click on the sheet name and select View code to open the VBA application.

Right-click > View Code.

Step 2

Then click on Insert and select Module, then copy the below code into the text box.

Insert > Module > Copy.

Code

Sub TrimExcessSpaces()
Dim Rng As Range
Dim WorkRng As Range
On Error Resume Next
xTitleId = "Remove Extra Spaces"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
For Each Rng In WorkRng
   Rng.Value = Application.WorksheetFunction.Trim(Rng.Value)
Next
End Sub

Step 3

Then click F5 to run the module. Then select the range of cells and click to complete the task. Then you will see that extra spaces will be removed from the strings.

F5 > Select Cells > OK.

This is how you can remove extra spaces from words in Excel.

Conclusion

In this tutorial, we have used a simple example to demonstrate how you can remove extra spaces between words in cells in Excel to highlight a particular set of data.

Updated on: 07-Sep-2023

80 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements