Remove spacing in excel

Excel for Microsoft 365 Excel 2021 Excel 2019 Excel 2016 Excel 2013 More…Less

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

  • Tighten the spacing for text inside a cell

  • Increase the spacing for text in a cell

  • Replace the text in a cell with a text box

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.

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

    On the right-click menu, click Format Cells.

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

    The Alignment tab of the Format Cells dialog box.

  3. Click OK. The text is evenly spaced.

    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.

Top of Page

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.

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

  2. On the Alignment tab, change Vertical to Justify.

  3. Click OK.

    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.

Top of Page

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.

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

    The text is selected.

  2. Click another cell to deselect the cell.

  3. Adjust the height of the row, if needed.

  4. On the Insert tab, click Text Box.

    Click Text Box.

  5. 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.

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

    The new text is pasted in the text box.

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

    On the right-click menu, click Paragraph.

  8. Select the line spacing you want.

    Image of the Paragraph dialog for editing text box text indents and spacing

    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.

Top of Page

See Also

Add, copy, or delete a text box

Change the format of a cell

Need more help?

Содержание

  1. Remove Spaces
  2. Remove Space in Excel
  3. Remove Spaces in Excel
  4. Top 5 Methods to Remove Spaces in Excel
  5. #1 – TRIM Function
  6. #2 – “Delimited” Option of Text to Columns Wizard
  7. #3 – “Fixed Width” Option of Text to Columns Wizard
  8. #4 – Find and Replace Option
  9. #5 – SUBSTITUTE Function
  10. Frequently Asked Questions
  11. Recommended Articles
  12. Remove Extra Spaces in Excel (Leading, Trailing, Double Spaces)
  13. How to Remove Spaces in Excel
  14. Using the TRIM Function
  15. Remove Extra Spaces in Excel using FIND and REPLACE
  16. Removing Double Spaces
  17. Removing Single Spaces
  18. Remove Line Breaks

Remove Spaces

The TRIM function in Excel removes leading spaces, extra spaces and trailing spaces. Use the SUBSTITUTE function to remove all spaces or non-breaking spaces.

1. The TRIM function below removes 2 leading spaces, 3 extra spaces and 2 trailing spaces.

Note: the TRIM function does not remove single spaces between words.

2. To get the length of a string, use the LEN function.

Explanation: the LEN function counts 2 spaces, 2 characters, 4 spaces, 3 characters and 2 spaces.

3. You can use the SUBSTITUTE function to remove all spaces.

Note: the SUBSTITUTE function substitutes spaces (second argument) with empty strings (third argument).

Text imported from other applications may contain ASCII characters. The CLEAN function removes the first 32 non-printable ASCII characters (codes 0 through 31).

4. The CLEAN function below removes a non-printable character, CHAR(7).

5. Simply combine CLEAN and TRIM to remove non-printable characters and spaces.

6. The CLEAN function removes line breaks. To enter a line break, press ALT + ENTER.

7. You can also use the SUBSTITUTE function to remove a line break, CHAR(10), and replace it with something else. For example, a comma and a space.

The CLEAN function doesn’t remove all ASCII characters. Simply use the SUBSTITUTE function to remove other ASCII characters.

8. First, find out the code number of the character.

9. Next, use SUBSTITUTE and CHAR to return the text string without this character.

10. If your text contains non-breaking spaces, CHAR(160), the TRIM function doesn’t work.

11. You can use the SUBSTITUTE function to substitute non-breaking spaces, CHAR(160) with normal spaces, CHAR(32). Don’t forget to add a TRIM function to remove the extra spaces.

Источник

Remove Space in Excel

Remove Spaces in Excel

While 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.

For example, if a cell contains “ rose,” the leading spaces may be visible to the reader. However, if “rose ” is written in a cell, the two trailing spaces may not be easily caught by the user.

Since extra spaces may render the Excel formulas incorrect, it is essential to eliminate them.

Table of contents

Top 5 Methods to Remove Spaces in Excel

The five methods to remove extra spaces in Excel are listed as follows:

  1. TRIM function
  2. “Delimited” option of text to columns wizard
  3. “Fixed width” option of text to columns wizard
  4. Find and replace option
  5. SUBSTITUTE function

The user can select any of the techniques depending on the requirement. Let us discuss all the methods one by one, along with examples.

#1 – TRIM Function

The following data contains extra spaces in column A. We want to rewrite the data without these spaces in column B with the help of the TRIM function.

Step 1: In cell B1, enter the TRIM function.

Step 2: Select the cell A1.

Step 3: Press the “Enter” key. The extra spaces from the name are removed in cell B1, as shown in the following image.

Step 4: Copy or drag the formula to the remaining cells, as shown in the following image.

#2 – “Delimited” Option of Text to Columns Wizard

The following data contains spaces in column A. We want to split the words of column A into separate cells in such a way that the space between the strings is eliminated.

Use the “delimited” option of the text to columns wizard.

Step 1: Select column A. In the Data tab, click “text to columns” from the “data tools” group. The same is shown in the following image.

Step 2: The “convert text to columns wizard” appears, as shown in the following image. Select the option “delimited” in “choose the file type that best describes your data.” Click “next.”

Step 3: Select “space” as the delimiter and click “finish.”

Step 4: The text strings of column A are split into two columns. The second half of the strings is placed in column B. The spaces between the strings have also been removed.

#3 – “Fixed Width” Option of Text to Columns Wizard

The “fixed width” option of the text to columns wizard helps remove extra spaces from numerical and textual data in Excel. For this, all the strings before the space should contain the same number of characters.

The following data contains random text and numbers with spaces in column A. We want to remove the spaces and split the strings into two separate columns.

Use the “fixed width” option of the text to columns wizard.

Step 1: Select column A. In the Data tab, click “text to columns” from the “data tools” group. The same is shown in the following image.

Step 2: The “convert text to columns wizard” appears, as shown in the following image. Select the option “fixed width” in “choose the file type that best describes your data.” Click “next.”

Step 3: Place the cursor at the position of the space. Click “finish.”

Step 4: The strings of column A are split into two columns. The second half of the strings is placed in column B. The spaces between the strings have also been removed.

Note: The text to columns wizard (methods #2 and #3) splits the data into different columns.

#4 – Find and Replace Option

Working on the excel data under the heading “TRIM function” (method #1), we want to remove spaces with the find and replace option.

Step 1: Press “Ctrl+H” and the “find and replace” dialog box is displayed, as shown in the following image.

Step 2: Enter a space in the “find what” box. Leave the “replace with” box blank. Click “replace all.”

Step 3: Excel displays a message stating the number of replacements. Click “Ok.”

Step 4: All the spaces in column A have been removed, as shown in the following image.

#5 – SUBSTITUTE Function

Working on the data under the heading “TRIM function” (method #1), we want to remove spaces in excel with the SUBSTITUTE function.

Step 1: In cell B1, enter the SUBSTITUTE function. Click “insert function” in the Formulas tab. The “function arguments” dialog box appears, as shown in the following image.

Step 2: Since the text in which characters are to be substituted is present in cell A1, enter the same in the “text” box.

Step 3: Since extra spaces are to be removed, enter “ ” in the “old_text” box. The blank between a pair of double quotation marks refers to a space.

Step 4: Since the space character is to be replaced with the existing text, enter “” in the “new_text” box. The pair of double quotation marks with no character in-between implies no spaces. Click “Ok.”

Step 5: The extra spaces from the name are removed in cell B1, as shown in the following image.

Step 6: Copy or drag the formula to the remaining cells, as shown in the following image.

Note: The find and replace option and the SUBSTITUTE function (methods #4 and #5) display the entire text string together without spaces.

Frequently Asked Questions

While working with Excel, there might be extra spaces that are not easily visible to the user. It is important to eliminate them for the following reasons:

• The spaces at inappropriate places can make the data look untidy and disordered.
• The extra spaces have a negative impact on the quality of data presentation.
• The unwanted spaces can mess up with the formulas of Excel.
• Two cells with and without spaces are considered different entries even though the data in both may be identical.

Since it is difficult to remove the extra spaces manually, there are various techniques available in Excel for such deletions.

Leading spaces are the extra space characters entered at the beginning of a data string. In contrast, the trailing spaces are found at the end of a string without any character following them.

The TRIM function helps remove all the unwanted spaces of the database. The exception to this rule is the single space character inserted between the words.

The syntax of the TRIM function is stated as follows:

The “text” represents the cell from which excess spaces are to be removed.

For example, the text string “ Chicago, United States ” in cell C2 is changed to “Chicago, United States” by the formula “=TRIM(C2).”

To remove all the spaces in Excel, use the following formula:

The space (“ ”) is replaced by the existing data (“”) in the cell C2.

For example, the text string “Chicago, United States” in cell C2 is changed to “Chicago,United States” by the given formula.

Note: Alternatively, the find and replace option can be used to remove all the spaces of a data string.

Recommended Articles

This has been a guide to removing spaces in excel cells. We discuss how to remove Leading, Trailing, Blank, Extra Spaces along with step by step examples. You may download an Excel template from the website. For more on Excel, take a look at the following articles –

Источник

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:

Источник

The TRIM function in Excel removes leading spaces, extra spaces and trailing spaces. Use the SUBSTITUTE function to remove all spaces or non-breaking spaces.

1. The TRIM function below removes 2 leading spaces, 3 extra spaces and 2 trailing spaces.

Remove Spaces in Excel

Note: the TRIM function does not remove single spaces between words.

2. To get the length of a string, use the LEN function.

Len Function

Explanation: the LEN function counts 2 spaces, 2 characters, 4 spaces, 3 characters and 2 spaces.

3. You can use the SUBSTITUTE function to remove all spaces.

Remove All Spaces

Note: the SUBSTITUTE function substitutes spaces (second argument) with empty strings (third argument).

Text imported from other applications may contain ASCII characters. The CLEAN function removes the first 32 non-printable ASCII characters (codes 0 through 31).

4. The CLEAN function below removes a non-printable character, CHAR(7).

Clean Function

5. Simply combine CLEAN and TRIM to remove non-printable characters and spaces.

Clean and Trim Function

6. The CLEAN function removes line breaks. To enter a line break, press ALT + ENTER.

Remove Line Breaks

7. You can also use the SUBSTITUTE function to remove a line break, CHAR(10), and replace it with something else. For example, a comma and a space.

Substitute Line Breaks

The CLEAN function doesn’t remove all ASCII characters. Simply use the SUBSTITUTE function to remove other ASCII characters.

8. First, find out the code number of the character.

Code Number

9. Next, use SUBSTITUTE and CHAR to return the text string without this character.

Substitute Function

10. If your text contains non-breaking spaces, CHAR(160), the TRIM function doesn’t work.

Non-breaking Spaces

11. You can use the SUBSTITUTE function to substitute non-breaking spaces, CHAR(160) with normal spaces, CHAR(32). Don’t forget to add a TRIM function to remove the extra spaces.

Remove Non-breaking Spaces

  1. Image titled Remove Spaces Between Characters and Numbers in Excel Step 1

    1

    Highlight the range in which you want to remove all spaces. For example, if you want to remove spaces from C2 through C30, highlight those cells.

  2. Image titled Remove Spaces Between Characters and Numbers in Excel Step 2

    2

    Click the Edit menu.

    Advertisement

  3. Image titled Remove Spaces Between Characters and Numbers in Excel Step 3

    3

    Select Find.

  4. Image titled Remove Spaces Between Characters and Numbers in Excel Step 4

    4

    Select Replace…. A dialog box will appear.

  5. Image titled Remove Spaces Between Characters and Numbers in Excel Step 5

    5

    Click the box beneath “Find What.”

  6. Image titled Remove Spaces Between Characters and Numbers in Excel Step 6

    6

    Press the space bar on the keyboard. Make sure to press it only once.

  7. Image titled Remove Spaces Between Characters and Numbers in Excel Step 7

    7

    Click Replace All. It’s the second button at the bottom of the window. The spaces are now removed from the selected cells. A pop-up will appear, letting you know how many spaces were removed.

  8. Image titled Remove Spaces Between Characters and Numbers in Excel Step 8

    8

    Click OK.

  9. Advertisement

  1. Image titled Remove Spaces Between Characters and Numbers in Excel Step 9

    1

    Click the top cell in a blank column. The cell must be on the same row as the first line of data in the column with the spaces.

    • For example, if you want to remove spaces from column C, and C’s first row of data is in row 2 (C2), click the second cell in your blank column (e.g. E2, F2, G2, etc).
  2. Image titled Remove Spaces Between Characters and Numbers in Excel Step 10

    2

    Type =Substitute.[1]

  3. Image titled Remove Spaces Between Characters and Numbers in Excel Step 11

    3

    Click the first cell in the column with spaces. For example, if you want to remove all of the spaces from the C column, click the first box (e.g. C2) in the column that isn’t the title.

    • If you clicked cell C2, the formula should now look like this: =Substitute(C2 .
  4. Image titled Remove Spaces Between Characters and Numbers in Excel Step 12

    4

    Type , (a comma). The cell should now look like this: =Substitute(C2,.

  5. Image titled Remove Spaces Between Characters and Numbers in Excel Step 13

    5

    Type " ",. There’s a space between the two sets of quotes—this is important.

    • The formula should now look like this: =Substitute(C2," ",.
  6. Image titled Remove Spaces Between Characters and Numbers in Excel Step 14

    6

    Type ””). This time, there’s NO space between the sets of quotes.

    • The formula should now look like this: =Substitute(C2,” “,””).
  7. Image titled Remove Spaces Between Characters and Numbers in Excel Step 15

    7

    Press Enter or Return. You will now see the contents of the selected cell (C2, in this example) without spaces in the new column.

    • For example, if C2 said w ww . wikih ow .com, your new cell will say www.wikihow.com.
  8. Image titled Remove Spaces Between Characters and Numbers in Excel Step 16

    8

    Click the cell with the formula you typed. The cell should now be highlighted.

  9. Image titled Remove Spaces Between Characters and Numbers in Excel Step 17

    9

    Drag the fill handle down over the cells you want to fill. The data from each corresponding cell will now appear in your new column without spaces.

  10. Image titled Remove Spaces Between Characters and Numbers in Excel Step 18

    10

    Copy the data from the new column to the original column. Your new space-free data is now in place.

  11. Advertisement

Ask a Question

200 characters left

Include your email address to get a message when this question is answered.

Submit

Advertisement

Thanks for submitting a tip for review!

About This Article

Thanks to all authors for creating a page that has been read 72,767 times.

Is this article up to date?

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

Понравилась статья? Поделить с друзьями:
  • Remove spacing between words in word
  • Remember the word combinations where the indefinite article is used
  • Remove spaces in between words in word
  • Remember the word book
  • Remove space from excel