Leading spaces in excel

How to Remove Leading Spaces in Excel Cell?

In Excel, unwanted space characters often take considerable time to clean and make the data perfect. One of the biggest problems with these unwanted leading spaces in Excel cells is that we cannot simply recognize a space in it. It adds to the misery.

Table of contents
  • How to Remove Leading Spaces in Excel Cell?
    • #1 – Remove Unwanted Leading Spaces in Excel Cell Using TRIM Function
    • #2 – Remove Non-Breaking Leading Spaces in Excel Cell
    • #3 – Remove Double Spaces Using Excel FIND & REPLACE Method
    • #4 – Remove All Leading Spaces Using Excel FIND & REPLACE Method
    • Things to Remember
    • Recommended Articles

#1 – Remove Unwanted Leading Spaces in Excel Cell Using TRIM Function

Let us start.

  1. Yes, you could argue why we don’t replace space with anything. But the problem is it will also replace all the necessary spaces. For example, look at the below sentence in a cell.

    Remove Space Example 1

    In the above sentence, we need one space character after each completed word to make the sentence proper. We have only one extra space after the word “Capital.”

  2. To deal with these unwanted space problems, we have a built-in function called TRIM in Excel, which can remove all the unwanted spaces in the Excel cells.

    Trim Formula

  3. The syntax is very simple. We need to select the required cell to be trimmed. The TRIM function removes all the spaces except the single space after each word. Let us apply the TRIM formula in Excel to remove all kinds of spaces in a cell.

    Remove Space Example 1-1

  4. This TRIM function removed the spaces between “Capital” and “is.”

    Remove Space Example 1-2

#2 – Remove Non-Breaking Leading Spaces in Excel Cell

It is very easy to remove normal leading spaces in the Excel cell. However, the TRIM function goes wrong in the case of non-breaking leading spaces. For example, look at the below image.

Remove Space Example 2

Even after the TRIM function is applied, we do not see the perfect sentence here. It is a problem with non-breaking leading spaces in an Excel cell.

Non-Breaking Leading Spaces in Excel Cell usually comes when we download the data from a web made up of the character CHAR (160). Therefore, we must use TRIM and SUBSTITUTE excel functionsSubstitute function in excel is a very useful function which is used to replace or substitute a given text with another text in a given cell, this function is widely used when we send massive emails or messages in a bulk, instead of creating separate text for every user we use substitute function to replace the information.read more in these cases together.

Firstly, open the TRIM function.

Remove Space Example 2-1

Now, apply the SUBSTITUTE function.

Remove Space Example 2-2

We need to select the text now, so select the A4 cell as the reference.

Remove Space Example 2-3

What is the old text we need to remove here? The old text is CHAR (160).

Remove Space Example 2-4

New text to be a substitute is nothing, so mention double quotes (“).

Remove Space Example 2-5

Close the bracket and press the “Enter” key. We will get a proper sentence now.

Remove Space Example 2-6

This way, we can deal with breaking spaces in the Excel cell. If the TRIM function cannot give accurate results, use this technique.

#3 – Remove Double Spaces Using Excel FIND & REPLACE Method

We can remove double spacesWhile importing or copy-pasting the data from an external source, extra spaces are also copied in Excel. This makes the data disorganized and difficult to be used. The purpose of removing unwanted spaces from the excel data is to make it more presentable and readable for the user.
read more
in cells using the Excel find and replaceFind and Replace is an Excel feature that allows you to search for any text, numerical symbol, or special character not just in the current sheet but in the entire workbook. Ctrl+F is the shortcut for find, and Ctrl+H is the shortcut for find and replace.read more method. For example, assume below is the data we have in Excel.

Remove Space Example 3

Here, we have a first name and last name together. After the first name, we have two spaces instead of one space. Instead of the TRIM function, we can use the find and replace method in these cases.

Step 1: Select the required area’s double space to be removed.

Remove Space Example 3-1

Step 2: Now, press “CTRL + H.”

Shortcut for Find & Replace

You will see below the “Find and Replace” window.

Remove Space Example 3-2

Step 3: Type two space characters in the “Find what:” box.

Remove Space Example 3-3

Step 4: Now, in the “Replace with:” type only one space character.

Remove Space Example 3-4

Step 5: Now, click on “Replace All.

Remove Space Example 3-5

Step 6: Excel will show you how many replacements it has made.

Remove Space Example 3-6

Step 7: It has removed all the double spaces in the Excel cell and replaced them with a single space. So, we have proper names now.

Remove Space Example 3-7

#4 – Remove All Leading Spaces Using Excel FIND & REPLACE Method

Assume you are working with numbers. You have many spaces between the numbers, as shown in the image below.

Example 4

We have abnormal Excel leading spaces between, before, and after the numbers. In these cases, we need to remove all the spaces. So use the “Find and Replace” method.

  • Step 1: Select the data first.

Example 4-1

  • Step 2: Press “Ctrl + H” and type a single space in the “Find what:” box.

Example 4-2

  • Step 3: Do not insert anything in the “Replace what:” box. Just click on “Replace All.”

Example 4-3

  • Step 4: It will remove all the leading spaces in the Excel cell. We have numbers in order now.

Example 4-4

Things to Remember

  • If the FIND and REPLACE method is used to remove leading spaces in an Excel cell, selecting the range and performing the operation is important.
  • If downloading the data from the web and encountering the same space problem, we must use the SUBSTITUTE function to remove CHAR (160) along with the TRIM function.
  • To remove non-printable characters, we must use the CLEAN Excel functionClean Function in Excel is a text function that is used to clean the text with the characters that are not printed when we use the print option. To use this function, type =CLEAN( ) in a cell and provide a text as an argument.read more.

Recommended Articles

This article is a guide to Remove Leading Spaces in Excel Cell. Here, we discuss how to remove leading spaces in Excel along with practical examples and a downloadable Excel template. You may learn more about Excel from the following articles: –

  • VBA HyperlinkHyperlinks are URLs attached to a value that appear when we hover the mouse over it. When we click on it, the URL is opened. In VBA, we have an inbuilt property to create hyperlinks. We use the add method and the hyperlink statement to insert a hyperlink.read more
  • Remove Watermark in ExcelThe three methods for removing the watermark in Excel are: deleting the background, removing the watermark with the ‘Header & Footer’ function, and removing the watermark with the ‘Go to Special’ function.read more
  • Delete Blank Rows in ExcelThere are several methods for deleting blank rows from Excel: 1) Manually deleting blank rows if there are few blank rows  2)  Use the formula delete 3) Use the filter to find and delete blank rows.read more
  • How to Remove Duplicates in Excel?To remove duplicates from the excel column, the user can adopt any of the three well-known methods: Using data tools group, Using the advanced filter in excel, Conditional formatting in excel.read more

How do I remove leading or trailing spaces of all cells in an entire column?

The worksheet’s conventional Find and Replace (aka Ctrl+H) dialog is not solving the problem.

ChrisM's user avatar

ChrisM

1,5766 gold badges17 silver badges28 bronze badges

asked Mar 6, 2012 at 5:32

venkat's user avatar

6

Quite often the issue is a non-breaking spaceCHAR(160) — especially from Web text sources -that CLEAN can’t remove, so I would go a step further than this and try a formula like this which replaces any non-breaking spaces with a standard one

=TRIM(CLEAN(SUBSTITUTE(A1,CHAR(160)," ")))

Ron de Bruin has an excellent post on tips for cleaning data here

You can also remove the CHAR(160) directly without a workaround formula by

  • Edit …. Replace your selected data,
  • in Find What hold ALT and type 0160 using the numeric keypad
  • Leave Replace With as blank and select Replace All

answered Mar 6, 2012 at 11:35

brettdj's user avatar

brettdjbrettdj

54.6k16 gold badges113 silver badges176 bronze badges

1

If you would like to use a formula, the TRIM function will do exactly what you’re looking for:

+----+------------+---------------------+
|    |     A      |           B         |
+----+------------+---------------------+
| 1  | =TRIM(B1)  |  value to trim here |
+----+------------+---------------------+

So to do the whole column…
1) Insert a column
2) Insert TRIM function pointed at cell you are trying to correct.
3) Copy formula down the page
4) Copy inserted column
5) Paste as «Values»

Should be good to go from there…

brettdj's user avatar

brettdj

54.6k16 gold badges113 silver badges176 bronze badges

answered Mar 6, 2012 at 5:49

hydrox467's user avatar

hydrox467hydrox467

1,7051 gold badge12 silver badges15 bronze badges

7

Without using a formula you can do this with ‘Text to columns’.

  • Select the column that has the trailing spaces in the cells.
  • Click ‘Text to columns’ from the ‘Data’ tab, then choose option ‘Fixed width’.
  • Set a break line so the longest text will fit. If your largest cell
    has 100 characters you can set the breakline on 200 or whatever you
    want.
  • Finish the operation.
  • You can now delete the new column Excel has created.

The ‘side-effect’ is that Excel has removed all trailing spaces in the original column.

coip's user avatar

coip

1,23216 silver badges30 bronze badges

answered May 9, 2017 at 15:27

Joris's user avatar

JorisJoris

1811 silver badge2 bronze badges

4

If it’s the same number of characters at the beginning of the cell each time, you can use the text to columns command and select the fixed width option to chop the cell data into two columns. Then just delete the unwanted stuff in the first column.

answered Mar 10, 2012 at 2:06

Katherine Chalmers's user avatar

0

I’ve found that the best (and easiest) way to delete leading, trailing (and excessive) spaces in Excel is to use a third-party plugin. I’ve been using ASAP Utilities for Excel and it accomplishes the task as well as adds many other much-needed features. This approach doesn’t require writing formulas and can remove spaces on any selection spanning multiple columns and/or rows. I also use this to sanitize and remove the uninvited non-breaking space that often finds its way into Excel data when copying-and-pasting from other Microsoft products.

More information regarding ASAP Utilities and trimming can be found here:

http://www.asap-utilities.com/asap-utilities-excel-tools-tip.php?tip=87enter image description here

answered Sep 19, 2017 at 15:45

James Moberg's user avatar

James MobergJames Moberg

4,3201 gold badge23 silver badges21 bronze badges

I was able to use Find & Replace with the «Find what:» input field set to:

» * «

(space asterisk space with no double-quotes)

and «Replace with:» set to:

«»

(nothing)

Cody Gray's user avatar

Cody Gray

237k50 gold badges488 silver badges570 bronze badges

answered Mar 30, 2017 at 20:05

Mr Roman's user avatar

1

Watch Video – Remove Spaces in Excel

Leading and trailing spaces in Excel often leads to a lot of frustration. I can’t think of a situation where you may need these extra spaces, but it often finds its way into the excel spreadsheets.

There are many ways you can end up with these extra spaces – for example, as a part of the data download from a database, while copying data from a text document, or entered manually by mistake.

Leading, trailing, or double space between text could lead to a lot of serious issues.

For example, suppose you have a data set as shown below:

How to Remove Spaces in Excel - Leading, Trailing and Double - Dataset

Now have a look at what happens when I use a VLOOKUP function to get the last name using the first name.

How to Remove Spaces in Excel - Leading, Trailing and Double - Vlookup Error

You might not be able to spot the difference with the naked eye that there is an extra trailing space in the name that is causing this error.

How to Remove Spaces in Excel - Leading, Trailing and Double - Trailing space

In this example, it was easy to spot the issue in such a small data set, but imagine having to check this for thousands of records.

To be on the safe side, it is always a good idea to clean your data and remove spaces in Excel.

How to Remove Spaces in Excel

In this tutorial, I will show you two ways to remove spaces in Excel.

  • Using TRIM function.
  • Using Find and Replace.

Using the TRIM Function

Excel TRIM function removes the leading and trailing spaces, and double spaces between text strings.

For example, in the above example, to remove spaces from the entire list if first names (in A2:A7), use the following formula in cell C1 and drag it down for all the first names:

=TRIM(A2)

Excel TRIM function would instantly remove all the leading and trailing spaces in the cell.

Once you have the cleaned data, copy it paste it as values in place of the original data.

How to Remove Spaces in Excel - Leading, Trailing and Double - Paste as Vaues

This function is also helpful if you have more than one space character between words. It would remove the extra spaces such that the result always have one space character between words.

How to Remove Spaces in Excel - Leading, Trailing and Double - space in between

Excel TRIM function does a good job in removing spaces in Excel, however, it fails when you have non-printing characters (such as line breaks) in your data set. To remove non-printing characters, you can use a combination of TRIM and CLEAN functions.

If you have some text in cell A1 from which you want to remove spaces, use the below formula:

=TRIM(CLEAN(A1))

Non-printing characters can also result from =CHAR(160), which can not be removed by the CLEAN formula. So, if you want to be absolutely sure that you have all the extra spaces and non-printing characters, use the below formula:

=TRIM(CLEAN(SUBSTITUTE(A1,CHAR(160)," ")))

Remove Extra Spaces in Excel using FIND and REPLACE

You can remove spaces in Excel using the Find and Replace functionality.

This is a faster technique and can be useful in the given situations:

  • When you want to remove double spaces.
  • When you want to remove all the space characters.

Removing Double Spaces

Note that this technique cannot be used to remove leading or trailing spaces. It will find and replace double spaces irrespective of its position.

Here are the steps to do this:

This will replace all the double spaces with a single space character.

How to Remove Spaces in Excel - Leading, Trailing and Double - Remove double

Note that this will only remove double spaces. If you have three space characters in between 2 words, it would result in 2 space characters (would remove one). In such cases, you can do this again to remove and any double spaces that might have been left.

Removing Single Spaces

To remove all the space characters in a data set, follow the below steps:

This will remove all the space characters in the selected data set.

How to Remove Spaces in Excel - Leading, Trailing and Double - Remove Single Space

Note that in this case, even if there are more than one space characters between two text strings or numbers, all of it would be removed.

Remove Line Breaks

You can also use Find and Replace to quickly remove line breaks.

Here are the steps to do this:

  • Select the data.
  • Go to Home –> Find and Select –> Replace (Keyboard Shortcut – Control + H).
  • In the Find and Replace Dialogue Box:
    • Find What: Press Control + J (you may not see anything except for a blinking dot).
    • Replace With: Leave it empty.How to Remove Spaces in Excel - Leading, Trailing and Double - Control J
  • Replace All.

This will instantly remove all the line breaks from the data set that you selected.

Based on your situation, you can choose either method (formula or find and replace) to remove spaces in Excel.

You may also like the following Excel tutorials:

  • Find and Remove Duplicates in Excel.
  • 10 Super Neat Ways to Clean Data in Excel.
  • MS Help – Remove Space and Non-printing characters.
  • How to Remove the First Character from a String in Excel
  • How to Remove Time from Date in Excel

Remove Leading Spaces in Excel

Excel Remove Leading Spaces (Table of Contents)

  • Remove Leading spaces in Excel
  • How to 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 which we may not observe while working in Excel. Different spaces available are Leading spaces/Trailing spaces, additional spaces, and line breaks in Excel.

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 that has data of 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. Now apply the same Vlookup by adding the spaces before the name and check whether the Vlookup is working or not. 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.

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 space after the name will cause any problem 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.

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

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 thereafter 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 in between the names then we will see whether Vlookup will give results.

Remove Leading Spaces Example 3-2

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

Example #4 – Using TRIM Function

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

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 in 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, in 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, which is marked with an arrow mark. If we observe the column with the name “After trim” has A and B in the same way in all the 3 cells, this is because the Trim function removes the additional spaces between A and B. The length of the column after the trim is 3 for all the cells.

Remove Leading Spaces Example 4-3

If we observe 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 are unable to remove all spaces using Trim, we can use the substitute function to remove all the spaces in the cell.

Consider the below table where there are spaces available in both the cells; however, the excel user do 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. Still, there is a space between and 5 in the first row, and there is a space between 6 and / in the second row. The length of cells after the trim is 7.

Now apply the Substitute function and check the lengths. 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 other cell and check the length of the results from the substitute; it is 6 for both the cells, which means there is no space available in both the cells.

Remove Leading Spaces Example 5-5

Example #6 – Remove Line Breaks in Excel

In case if 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 it 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 has been a guide to Remove Leading Spaces in Excel. Here we discussed How to Remove Leading Spaces in Excel along with 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

Содержание

  1. Change line spacing
  2. In this article
  3. Tight the spacing for text inside a cell
  4. Increase the spacing for text in a cell
  5. Replace the text in a cell with a text box
  6. Start a new line of text inside a cell in Excel
  7. Need more help?
  8. Remove Extra Spaces in Excel (Leading, Trailing, Double Spaces)
  9. How to Remove Spaces in Excel
  10. Using the TRIM Function
  11. Remove Extra Spaces in Excel using FIND and REPLACE
  12. Removing Double Spaces
  13. Removing Single Spaces
  14. Remove Line Breaks
  15. 3 ways to remove spaces between words / numbers in Excel cells
  16. Trim blanks between words to 1, remove trailing / leading spaces
  17. Use the Trim formula to remove extra spaces
  18. Using Find & Replace to remove extra spaces between words
  19. 3 clicks to neat data with Trim Spaces tool
  20. Remove all spaces between numbers
  21. Using formula to remove all spaces

Change line spacing

You might want to improve the look of the text inside a cell by changing the vertical line spacing. Although Excel offers no direct control for line spacing within a cell, you can use several text alignment strategies to adjust white space or make the text more readable. You can also add a text box, which offers more control.

In this article

Tight the spacing for text inside a cell

If your text inside a cell is too widely spaced, it might be vertically justified. You can often improve readability by changing the Text alignment to get the lines closer together.

Right-click inside the cell you want to change, and click Format Cells.

On the Alignment tab, change Vertical to Top, Center, or Bottom, depending on where you want your text to be placed inside the cell.

Click OK.

Your text is now aligned and evenly spaced where you wanted it.

Tip: If you have lots of white space in one cell because another cell on the same row has more content, you can change the vertical alignment for the cell with too much space to Center to fill the space more evenly.

Increase the spacing for text in a cell

If your cell has white space, and you want to increase the line space to fill it evenly, change the vertical spacing to Justify.

Right-click in the cell you want, and click Format cells.

On the Alignment tab, change Vertical to Justify.

Your text is now distributed evenly inside the cell. If you change the height of the row, the text re-adjusts evenly to the new width.

Replace the text in a cell with a text box

If you have only few cells with text that need to be modified, you can consider inserting a text box on top of the cell. By using a text box instead of a cell, you have more control over text formatting.

Double-click the cell you want to modify, select all of the text in it, and press Ctrl+X.

Click another cell to deselect the cell.

Adjust the height of the row, if needed.

On the Insert tab, click Text Box.

Move the cursor to the upper-left corner of the cell you want, and click and hold to draw a text box that fits the cell. If you need to adjust the size of the text box after creating it, drag the selection squares at the edges.

Click in the text box to activate it, and press Ctrl+V to paste your text inside the text box.

Select all of the text in the text box, right-click it, and click Paragraph.

Select the line spacing you want.

Tip: You can also tighten the text by reducing the font size. Select the text, then right-click on it, click Font, and select the font size you want.

Note: The text box is not inside the cell but floats over it. If the row on which it was inserted moves as the content above is changed, the text box does not move along with the cell. To move the text box, move the cursor to the edge of the text box, and click and hold to drag the text box to a new location.

Источник

Start a new line of text inside a cell in Excel

To start a new line of text or add spacing between lines or paragraphs of text in a worksheet cell, press Alt+Enter to insert a line break.

Double-click the cell in which you want to insert a line break.

Click the location inside the selected cell where you want to break the line.

Press Alt+Enter to insert the line break.

To start a new line of text or add spacing between lines or paragraphs of text in a worksheet cell, press CONTROL + OPTION + RETURN to insert a line break.

Double-click the cell in which you want to insert a line break.

Click the location inside the selected cell where you want to break the line.

Press CONTROL+OPTION+RETURN to insert the line break.

To start a new line of text or add spacing between lines or paragraphs of text in a worksheet cell, press Alt+Enter to insert a line break.

Double-click the cell in which you want to insert a line break (or select the cell and then press F2).

Click the location inside the selected cell where you want to break the line.

Press Alt+Enter to insert the line break.

Double-tap within the cell.

Tap the place where you want a line break, and then tap the blue cursor.

Tap New Line in the contextual menu.

Note: You cannot start a new line of text in Excel for iPhone.

Tap the keyboard toggle button to open the numeric keyboard.

Press and hold the return key to view the line break key, and then drag your finger to that key.

Need more help?

You can always ask an expert in the Excel Tech Community or get support in the Answers community.

Источник

Watch Video – Remove Spaces in Excel

Leading and trailing spaces in Excel often leads to a lot of frustration. I can’t think of a situation where you may need these extra spaces, but it often finds its way into the excel spreadsheets.

There are many ways you can end up with these extra spaces – for example, as a part of the data download from a database, while copying data from a text document, or entered manually by mistake.

Leading, trailing, or double space between text could lead to a lot of serious issues.

For example, suppose you have a data set as shown below:

Now have a look at what happens when I use a VLOOKUP function to get the last name using the first name.

You might not be able to spot the difference with the naked eye that there is an extra trailing space in the name that is causing this error.

In this example, it was easy to spot the issue in such a small data set, but imagine having to check this for thousands of records.

To be on the safe side, it is always a good idea to clean your data and remove spaces in Excel.

This Tutorial Covers:

How to Remove Spaces in Excel

In this tutorial, I will show you two ways to remove spaces in Excel.

  • Using TRIM function.
  • Using Find and Replace.

Using the TRIM Function

Excel TRIM function removes the leading and trailing spaces, and double spaces between text strings.

For example, in the above example, to remove spaces from the entire list if first names (in A2:A7), use the following formula in cell C1 and drag it down for all the first names:

Excel TRIM function would instantly remove all the leading and trailing spaces in the cell.

Once you have the cleaned data, copy it paste it as values in place of the original data.

This function is also helpful if you have more than one space character between words. It would remove the extra spaces such that the result always have one space character between words.

Excel TRIM function does a good job in removing spaces in Excel, however, it fails when you have non-printing characters (such as line breaks) in your data set. To remove non-printing characters, you can use a combination of TRIM and CLEAN functions.

If you have some text in cell A1 from which you want to remove spaces, use the below formula:

Non-printing characters can also result from =CHAR(160), which can not be removed by the CLEAN formula. So, if you want to be absolutely sure that you have all the extra spaces and non-printing characters, use the below formula:

Remove Extra Spaces in Excel using FIND and REPLACE

You can remove spaces in Excel using the Find and Replace functionality.

This is a faster technique and can be useful in the given situations:

  • When you want to remove double spaces.
  • When you want to remove all the space characters.

Removing Double Spaces

Note that this technique cannot be used to remove leading or trailing spaces. It will find and replace double spaces irrespective of its position.

Here are the steps to do this:

This will replace all the double spaces with a single space character.

Note that this will only remove double spaces. If you have three space characters in between 2 words, it would result in 2 space characters (would remove one). In such cases, you can do this again to remove and any double spaces that might have been left.

Removing Single Spaces

To remove all the space characters in a data set, follow the below steps:

This will remove all the space characters in the selected data set.

Note that in this case, even if there are more than one space characters between two text strings or numbers, all of it would be removed.

Remove Line Breaks

You can also use Find and Replace to quickly remove line breaks.

Here are the steps to do this:

  • Select the data.
  • Go to Home –> Find and Select –> Replace (Keyboard Shortcut – Control + H).
  • In the Find and Replace Dialogue Box:
    • Find What: Press Control + J (you may not see anything except for a blinking dot).
    • Replace With: Leave it empty.
  • Replace All.

This will instantly remove all the line breaks from the data set that you selected.

Based on your situation, you can choose either method (formula or find and replace) to remove spaces in Excel.

You may also like the following Excel tutorials:

Источник

3 ways to remove spaces between words / numbers in Excel cells

by Alexander Frolov, updated on March 15, 2023

3 quick ways to remove extra spaces between words or delete all spaces from Excel cells. You can use trim formula, Excel Find & replace or special Excel add-in to clean up cells’ content.

When you paste data from an external source to an Excel spreadsheet (plain text reports, numbers from web pages, etc.), you are likely to get extra spaces along with important data. There can be leading and trailing spaces, several blanks between words and thousand separators for numbers.

Consequently, your table looks disorderly and becomes difficult to use. It may be a challenge to find a customer in the Name column since you search for «John Doe» which has no excess spaces between the names while the way it looks in your table is «John Doe». Or numbers can’t be summed up, and again extra blanks are the ones to blame.

In this article you’ll find how to clean up your data.

Trim blanks between words to 1, remove trailing / leading spaces

For example, you have a table with 2 columns. In the column Name, the first cell contains «John Doe» written correctly without excess spaces. All other cells have extra blanks between the first and the last names. At the same time these cells have irrelevant blanks before and after the full names known as leading and trailing spaces. The second column is called Length and shows the number of symbols in each name:

Excel has the Trim formula to use for deleting extra spaces from text. Below you can find the steps showing how to use this option:

  1. Add the helper column to the end of your data. You can name it «Trim».
  2. In the first cell of the helper column (C2), enter the formula to trim excess spaces =TRIM(A2)

  • Copy the formula across the other cells in the column. Feel free to use some tips from Enter the same formula into all selected cells at a time.
  • Replace the original column with the one that has the cleaned data. Select all cells in the helper column and press Ctrl + C to copy data to clipboard.

    Now pick the first cell in the original column and press Shift + F10 or the menu button . Then just press V .

    Remove the helper column.

    That’s it! We deleted all excess blanks with the help of the formula trim(). Unfortunately, it’s a bit time-consuming, especially if your spreadsheet is rather big.

    Note. If after using the formula you still see extra spaces (the last cell on the screenshot), please have a look at If the TRIM function doesn’t work.

    This option needs fewer steps, but allows only deleting excess spaces between words. Leading and trailing spaces will also be trimmed to 1, but will not be removed.

    1. Select one or several columns with the data to delete spaces between words.
    2. Press Ctrl + H to get the «Find and Replace» dialog box.
    3. Press the Space bar twice in the Find What field and once in Replace With
    4. Click on the «Replace all» button, and then press Ok to close Excel confirmation dialog.

  • Repeat step 4 until you see the message «We couldn’t find anything to replace.» 🙂
  • 3 clicks to neat data with Trim Spaces tool

    If you often import data to Excel from external sources and spend much time polishing up your tables, check out our Text tools for Excel.

    The Trim Spaces add-in will clean data imported from the web or any other external source. It removes leading and trailing spaces, excess blanks between words, non-breaking spaces, line breaks, non-printing symbols and other unwanted characters. Also, there is an option to convert words to UPPER, lower or Proper Case. And if you need to change text numbers back to the number format and delete apostrophes, this will not be a problem either.

    To remove all extra spaces in your worksheet, including excess paces between words, this is what you need to do:

    1. Download and install a trial version of Ultimate Suite for Excel.
    2. Select the range in your table where you want to remove excess spaces. For new tables, I usually press Ctrl + A to process all columns in a go.
    3. Go to Ablebits Data tab and click on the Trim Spaces icon.

    The add-in’s pane will open on the left side of your worksheet. Just select the needed checkboxes, click the Trim button and enjoy your perfectly cleaned table.

    Isn’t it faster than with the two previous tips? If you always deal with data processing, this tool will save you hours of precious time.

    Remove all spaces between numbers

    Suppose, you have a workbook with numbers where the digits (thousands, millions, billions) are separated with spaces. Thus Excel sees numbers as text and no math operation can be performed.

    The easiest way to get rid of excess spaces is using the standard Excel Find & Replace option:

    • Press Ctrl + Space to select all cells in a column.
    • Press Ctrl + H to open the «Find & Replace» dialog box.
    • Press Space bar in the Find What field and make sure the «Replace with» field is empty.
    • Click on the «Replace all» button, and then press Ok. Voila! All spaces are removed.

    Using formula to remove all spaces

    You may need to delete all blanks, like in a formula chain. To do this, you can create a helper column and enter the formula: =SUBSTITUTE(A1,» «,»»)

    Here A1 is the first cell of the column with numbers or words where all spaces must be deleted.

    Источник

    Like this post? Please share to your friends:
  • Leadership in one word
  • Learning english word book
  • Latin word for scientist
  • Leaders of the word
  • Learning by word association