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

or
0
0
0
s2smodern

How to remove leading spaces in cells in Excel?

Sometimes there are some blank spaces before strings in cells, these spaces are called leading spaces. It must be arduous to remove leading spaces in cells one by one. Actually, there are several smart tricks that can help us remove leading spaces in cells conveniently and quickly. Suppose we paste some content from Microsoft Word with indent spaces, then it shows the leading spaces in each cell as the following screenshot shows.

Remove leading spaces in cells with Trim function

Remove leading spaces in cells with VBA

Remove leading spaces in cells with Kutools for Excelgood idea3


Quickly remove extra/leading/trailing spaces in Excel sheet

  Click for 60 days free trial!
doc remove spaces
 
Kutools for Excel: with more than 200 handy Excel add-ins, free to try with no limitation in 60 days.

arrow blue right bubble Remove leading spaces in cells with Trim function

Tabbed browsing & editing multiple Excel workbooks/Word documents as Firefox, Chrome, Internet Explore 10!

You may be familiar to view multiple webpages in Firefox/Chrome/IE, and switch between them by clicking corresponding tabs easily. Here, Office Tab supports similar processing, which allow you to browse multiple Excel workbooks or Word documents in one Excel window or Word window, and easily switch between them by clicking their tabs. Click for free trial of Office Tab!

ot excel

The Trim function in Microsoft Excel can remove all spaces from text except for single spaces between words.

Step 1: Enter the formula =TRIM (A1) in the adjacent cell C1 and press the Enter key.

Step 2: Select cell C1 and drag the fill handle down to the range cell that you want to remove the leading space. Then you can see all cell content are extracted with all leading spaces removed. See screenshot:

You can replace the original content with the extracted ones by copying and pasting them as values.

This method is quite easy if you only need to remove leading spaces in contiguous cells within a row or a column. However, when you need to remove leading spaces in a range with several rows and columns, you have to use the function several times.


arrow blue right bubble Remove leading spaces in cells with VBA

If you are experienced with Microsoft Excel,  VBA macro is a better choice to remove the leading spaces in cells.

Step 1: Hold down the Alt + F11 keys, and it opens the Microsoft Visual Basic for Applications window.

Step 2: Click Insert > Module, and paste the following macro in the Module window.

VBA: Remove leading spaces:

Sub RemoveLeadingSpace()
'Updateby20131129
Dim Rng As Range
Dim WorkRng As Range
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
For Each Rng In WorkRng
    Rng.Value = VBA.LTrim(Rng.Value)
Next
End Sub

Step 3: Press the F5 key to run this macro. In the pop-up KutoolsforExcel dialog box, you need to select a range with leading space you want to remove, and then click the OK button. See screenshot:

Then you can see all leading spaces are moved from the selected range, see screenshots:


arrow blue right bubble Remove leading spaces in cells with Kutools for Excel

If you have Kutools for Excel installed, you can remove all leading spaces of cells in a selection conveniently and quickly by its Remove Spaces utility.

Kutools for Excel, with more than 200 handy functions, makes your jobs easier. 

After installing Kutools for Excel, please do as below:(Free Download Kutools for Excel Now!)

Step 1: Select the range which you want to remove all leading spaces in cells.

Step 2: Click the Kutools > Text > Remove Spaces. See screenshot:

doc remove leading spaces 5

Step 3: In the Remove Spaces dialog box, check the Leading Spaces option in Spaces Type section, and then click the OK or Apply button. See screenshot:

doc remove leading spaces 6

Now all leading spaces are removed from the selected cells.

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.

Remoev trailing spaces -- check Trailig spaces option
doc remove leading spaces 7
Remoev extra spaces -- check All excess spaces option
doc remove leading spaces 8
Remoev all spaces -- check All spaces option
doc remove leading spaces 9

arrow blue right bubble Remove leading spaces in cells with Kutools for Excel

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

One click to remove all leading zeros from cells in Excel

Just one click, all leading zeros of the cells in seletion have been removed.  Click for 60 days free trial!
doc remov leading zero
 
Kutools for Excel: with more than 200 handy Excel add-ins, free to try with no limitation in 60 days.

Related articles:


Recommended Productivity Tools

Office Tab

gold star1 Bring handy tabs to Excel and other Office software, just like Chrome, Firefox and new Internet Explorer.

Kutools for Excel

gold star1 Amazing! Increase your productivity in 5 minutes. Don't need any special skills, save two hours every day!

gold star1 300 New Features for Excel, Make Excel Much Easy and Powerful:

  • Merge Cell/Rows/Columns without Losing Data.
  • Combine and Consolidate Multiple Sheets and Workbooks.
  • Compare Ranges, Copy Multiple Ranges, Convert Text to Date, Unit and Currency Conversion.
  • Count by Colors, Paging Subtotals, Advanced Sort and Super Filter,
  • More Select/Insert/Delete/Text/Format/Link/Comment/Workbooks/Worksheets Tools...

Screen shot of Kutools for Excel

btn read more      btn download     btn purchase

Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
People in conversation:
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Daniel Musyoka · 4 months ago
    KUTOOLS is one of the greatest Excel add-ins ever. Great insights above.
  • To post as a guest, your comment is unpublished.
    Sam Ried · 4 months ago
    Thanks for this wonderful article! hats off to your writing! great post with rich quality content! Very resourceful and informative! Keep posting! Would love to follow up on your upcoming future posts! Ninja Heroes Mod Apk
  • To post as a guest, your comment is unpublished.
    Shafiq · 1 years ago
    Its very helpful
  • To post as a guest, your comment is unpublished.
    win htet maung · 1 years ago
    Thanks for sharing....
  • To post as a guest, your comment is unpublished.
    yermum · 1 years ago
    So, this is simply a marketing page for a product that has no need to exist?