How to Remove a Space after a Number in Excel (6 Easy Ways)

The below dataset contains the names of 4 products and their codes. The product codes contain extra spaces after numbers.

6 Easy Ways to Remove Space after Number in Excel


Method 1 – Using the TRIM Function

Steps:

  • Insert an additional column: ‘Cleaned Value’.

Use TRIM Function to Remove Space after Number in Excel

  • Select cell D5.
  • Enter the following formula:
=TRIM(C5)
  • Press Enter.
  • The value of cell C5 is now in D5 without spaces.

Use TRIM Function to Remove Space after Number in Excel

  • Drag the Fill Handle tool from cell D5 to D8. We get results like the following image.

Read More: How to Remove Space in Excel after Text


Method 2 – Using the Find and Replace Tool

Steps:

  • Select cells C5 to C8.

Delete Space after Number with Find and Replace Options

  • Go to the Home tab.

Delete Space after Number with Find and Replace Options

  • Select ‘Find & Select’.
  • From the drop-down menu select Replace.

Delete Space after Number with Find and Replace Options

  • A new pop-up window named ‘Find and Replace’ will open. (You can also press Ctrl + H to open that window.)
  • Click ‘Find what’ and press the Spacebar. (You can also click ‘Replace with’ and press the Spacebar.)
  • Click the ‘Replace All’ button.

  • We get results like the following image.

NOTE:  The Find & Replace options modify the source data. They remove all spaces from the original values.

Read More: How to Remove Space between Rows in Excel


Method 3 –  Using the SUBSTITUTE Function

Steps:

  • Enter an additional column: ‘Cleaned Value’.

Apply SUBSTITUTE Function to Remove Space after Number

  • Select cell D5.
  • Enter the following formula:
=SUBSTITUTE(C5," ","")
  • Press Enter.
  • The value of cell C5 is now in cell D5 without spaces.

Apply SUBSTITUTE Function to Remove Space after Number

  • Drag the Fill Handle tool from cell D5 to D8.
  • This returns all the values of product codes without space in cells (D5:D8).

Read More: How to Remove Blank Spaces in Excel


Method 4 – Using VBA Macro

Steps:

  • Select cells (C5:C8).

VBA to Remove Space after Number in Excel

  • Right-click on the active sheet named VBA. Select the option ‘View Code’.

VBA to Remove Space after Number in Excel

  • A new blank VBA code window will appear. Enter the following code:
Sub Remove_Space()
Dim rng As Range
For Each rng In Selection.Cells
rng = Replace(rng, " ", "")
Next
End Sub
  • Click the Run button or press the F5 key to run the code.

  • We get a result like the following image.


Method 5 – Using the Power Query Tool

Steps:

  • Go to the Data tab.
  • Select the option ‘From Table/Range’.

Remove Extra Space after Number with Power Query

  • A new pop-up window named ‘Create Table’ opens.
  • Enter the table range $B$4:$C$8 in the text field named ‘Where is the data for your table?’.
  • Keep the field ‘My table has headers’ unchecked.
  • Click OK.

Remove Extra Space after Number with Power Query

  • The above command opens the power query editor.
  • Right-click on the heading Column2. Select ‘Replace Values’.

Remove Extra Space after Number with Power Query

  • A new pop-up window named ‘Replace Values’ opens.
  • Add two spaces in the ‘Value To Find’ field and a single space in the ‘Replace With’ field.
  • Click OK.

  • The values of the product codes are now without spaces, just like in the image below.

Read More: How to Remove Tab Space from Excel


Method 6 – Using Excel Delimited Option

Steps:

  • Select cells (C5:C8).

Eliminate Space after Number Using Excel Delimited Option

  • Go to the Data tab. Select ‘Text to Columns’.

Eliminate Space after Number Using Excel Delimited Option

  • A new pop-up window named ‘Convert Text to Columns Wizard’ opens.
  • Select the option Delimited in the ‘Choose the file type that best describes your data’ section. Click Next.

Eliminate Space after Number Using Excel Delimited Option

  • Check Space as Delimiters. Click Finish.

  • The results are like the following image.


Download the Practice Workbook

You can download the workbook to practice.


Related Articles

<< Go Back To Remove Space in Excel | Data Cleaning in Excel | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Mukesh Dipto
Mukesh Dipto

Mukesh Dipto is an excellent marine engineer who loves working with Excel and diving into VBA programming. For him, programming is like a superhero tool that saves time when dealing with data, files, and the internet. His skills go beyond the basics, including Rhino3D, Maxsurf C++, AutoCAD, HTML, CSS, JavaScript, and WordPress. He got his B.Sc in Naval Architecture & Marine Engineering from BUET, and now he's switched gears, working as a content developer. In this role, he... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo