EDUCBA

EDUCBA

MENUMENU
  • Blog
  • All Courses
  • All in One Bundle
  • Login
Home Excel Excel Resources Excel Tips Excel Remove Leading Spaces

Excel Remove Leading Spaces

Madhuri Thakur
Article byMadhuri Thakur

Updated August 21, 2023

Remove Leading Spaces in Excel

Remove Leading Spaces in Excel

While working in Excel, we frequently use the spaces for each word. There are different spaces in Excel that we may not observe while working in Excel. Different spaces available are Leading spaces/Trailing spaces, additional spaces, and line breaks in Excel. In this article, we will learn about Remove Leading Spaces in Excel.

Start Your Free Excel Course

Excel functions, formula, charts, formatting creating excel dashboard & others

How to Remove Leading Spaces in Excel?

In this article, first, we will see how to identify spaces between cells. These spaces may create a problem while working with formulas in Excel.

You can download this Remove Leading Spaces Excel Template here – Remove Leading Spaces Excel Template

We will see a few examples where it causes a problem. We will use formulas and functions to remove spaces in Excel.

Example #1

Consider a sheet with data on student names and roll numbers as below.

Student's Data Sheet

Now we will apply Vlookup for the first table to find the Roll numbers from the second table. The results will be like the below screenshot after we apply the Vlookup.

Remove Leading Spaces Example 1-2

You may doubt why we are discussing Vlookup now. Observe the below screenshot; for the names “Kiran” and “Kumar “, we gave spaces; hence the roll number is coming as N/A for both student names. Now apply the same Vlookup by adding the spaces before the name and check whether the Vlookup is working.

Remove Leading Spaces Example 1-3

This is because due to the spaces at the beginning of the names. Now we have seen the problem is due to the space available in the beginning.

Example #2

Now we will check if the space after the name will cause any problems while applying formulas. We will keep the space after the names “Kiran” and “Rajesh” why I am mentioning the names because we cannot identify if space is available after the name.

We can use the formula length and find to know the number of spaces available. Observe the below screenshot. I have applied the LEN formula for the same names in both tables, but the length is different.

In the first table, we have given space after the name; hence length is 7 for the same names, and in the second table, it is 6. I hope you understand how the spaces will affect the formula and how to find whether spaces are there or not.

Remove Leading Spaces Example 2-1

Example #3

If space is there in the beginning and space is after that now, we will see if the space is available in between two words.

Remove Leading Spaces Example 3-1

If we observe, there is space between every word, and I have also given the length for those two names. We will add one more space between the names and then see whether Vlookup will give results.

Remove Leading Spaces Example 3-2

I hope you understand how spaces create errors while working with formulas in Excel. I added the space for “Rachel Green” in the first table and “Virat Singh” in the second table. Because of that, two of them gave the results as “N/A”.

Example #4 – Using the TRIM Function

The fast and easy way to remove spaces in Excel is by using the TRIM function. Now we will apply the Trim function and check the words’ length.

Consider the below table with different types of spaces between A and B.

Remove Leading Spaces Example 4-1

In the first line, only one space is given between A and B under the Alphabet column, and the length of that cell is 3 because it has two characters and one space. The second line has three spaces between A and B and one space after B; hence the length of that cell is 6, and the final cell is given multiple spaces before A, between A and B, and after B.

Remove Leading Spaces Example 4-2

Now apply the “Trim” function to remove the additional spaces between A and B. We can observe the formula bar, marked with an arrow mark. If we observe that the column with the name “After trim” has A and B in the same way in all 3 cells, the Trim function removes the additional spaces between A and B. The column length after the trim is 3 for all the cells.

Remove Leading Spaces Example 4-3

Suppose the trim function left only one space between A and B but removes the additional spaces between A and B before and after A and B. So, with the help of the Trim function, we cannot remove entire spaces between the words except additional spaces.

Example #5 – Removal of All Spaces in Excel

As we cannot remove all spaces using Trim, we can use the substitute function to remove all the spaces in the cell.

Consider the table below, where spaces are available in both cells; however, the Excel user does not want any spaces.

Data with Space

First, apply the Trim function and check.

Using Trim Function

Observe the results after applying a trimming function. The length of cells after the trim is 7. Still, there is a space between – and 5 in the first row, and there is a space between 6 and / in the second row.

Now apply the Substitute function and check the lengths. The substitute function is used to replace one text with another text. Here we need to replace space with no space or null. Observe the format of the substitute function in the below screenshot.

Remove Leading Spaces Example 5-3

As per the above screenshot in “Text”, we selected the cell address as A2, and “Old_text” is space; hence given space between double quotes, and “new_text” is null; hence we were just given double quotes without space.

Substitute Function

Follow the same steps for the other cells and check the length of the results from the substitute; it is 6 for both cells, which means there is no space available in both cells.

Remove Leading Spaces Example 5-5

Example #6 – Remove Line Breaks in Excel

In case your Excel has line breaks in the same cell, there are two different lines, as shown in the screenshot below.

Line Breaks

Observe “I love” in one line and “dogs” in the next line but belong to the same cell A1. If we want to remove the line breakages like this, we can use the “Clean” function without removing the additional spaces.

Using Clean Function

Things to Remember

  • Additional spaces in Excel will create disturbances while applying formulas in Excel.
  • There are different spaces like Leading/Trailing/In-between.
  • The trim function helps remove all the additional spaces but will not remove only one space between words or letters.
  • If we want to remove all the spaces, we can use the Substitute function.
  • If there are any line breaks, we can use the Clean function, but it will not remove additional spaces but just remove line breaks.
  • We can also use find and replace to remove spaces.

Recommended Articles

This is a guide to Remove Leading Spaces in Excel. We discussed How to Remove Leading Spaces in Excel, practical examples, and a downloadable Excel template. You can also go through our other suggested articles –

  1. VLOOKUP Function in Excel
  2. SUBSTITUTE in Excel
  3. TRIM in Excel
  4. Excel CLEAN Function
MICROSOFT POWER BI Course Bundle - 8 Courses in 1
34+ Hours of HD Videos
8 Courses
Verifiable Certificate of Completion
Lifetime Access
4.5
MS Excel & VBA for Data Science Course Bundle - 24 Courses in 1 | 10 Mock Tests
87+ Hours of HD Videos
24 Courses
10 Mock Tests & Quizzes
Verifiable Certificate of Completion
Lifetime Access
4.5
All-in-One Financial Analyst Masters Training Program Bundle - 550+ Courses | 300+ Mock Tests | 2000+ Hours | Lifetime |
2000+ Hours of HD Videos
43 Learning Paths
550+ Courses
Verifiable Certificate of Completion
Lifetime Access
4.9
All-in-One Data Science Bundle - 400+ Courses | 550+ Mock Tests | 2000+ Hours | Lifetime |
2000+ Hour of HD Videos
80 Learning Paths
400+ Courses
Verifiable Certificate of Completion
Lifetime Access
4.7
Primary Sidebar
Popular Course in this category
MS Excel Course Bundle - 36 Courses in 1 | 13 Mock Tests
 137+ Hours of HD Videos
36 Courses
13 Mock Tests & Quizzes
  Verifiable Certificate of Completion
  Lifetime Access
4.9
Price

View Course
Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Live Classes
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Excel Charts
  • Excel Tips
  • All Tutorials
Certification Courses
  • All Courses
  • Excel VBA Course - All in One Bundle
  • VBA Course
  • Excel Data Analysis Course
  • Excel for Marketing Course
  • Excel for Finance Course
  • Excel for HR Training

ISO 10004:2018 & ISO 9001:2015 Certified

© 2023 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA

Download Remove Leading Spaces Excel Template

Let’s Get Started

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

EDUCBA
Free Excel Course

Excel functions, formula, charts, formatting creating excel dashboard & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA Login

Forgot Password?

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA

Download Remove Leading Spaces Excel Template

EDUCBA

डाउनलोड Remove Leading Spaces Excel Template

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more