Delete space from excel

Excel for Microsoft 365 Excel for Microsoft 365 for Mac Excel for the web Excel 2021 Excel 2021 for Mac Excel 2019 Excel 2019 for Mac Excel 2016 Excel 2016 for Mac Excel 2013 Excel 2010 Excel 2007 Excel for Mac 2011 Excel Starter 2010 More…Less

This article describes the formula syntax and usage of the TRIM function in Microsoft Excel.

Description

Removes all spaces from text except for single spaces between words. Use TRIM on text that you have received from another application that may have irregular spacing.

Important: The TRIM function was designed to trim the 7-bit ASCII space character (value 32) from text. In the Unicode character set, there is an additional space character called the nonbreaking space character that has a decimal value of 160. This character is commonly used in Web pages as the HTML entity,  . By itself, the TRIM function does not remove this nonbreaking space character. For an example of how to trim both space characters from text, see Top ten ways to clean your data.

Syntax

TRIM(text)

The TRIM function syntax has the following arguments:

  • Text    Required. The text from which you want spaces removed.

Example

Copy the example data in the following table, and paste it in cell A1 of a new Excel worksheet. For formulas to show results, select them, press F2, and then press Enter. If you need to, you can adjust the column widths to see all the data.

Formula

Description

Result

=TRIM(» First Quarter Earnings «)

Removes leading and trailing spaces from the text in the formula (First Quarter Earnings)

First Quarter Earnings

Need more help?

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

Bottom Line: Learn 5 different techniques to find and remove spaces in Excel.  Spaces can cause formula errors and frustration with data preparation and analysis.

Skill Level: Intermediate

Watch the Tutorial

Watch on YouTube & Subscribe to our Channel

Download the Excel File

You can download the workbook that I use in the video, including the macro I wrote to remove blank spaces.

Space Hunting

Blank spaces can be a headache for data analysts and formula writers. That’s because they are not easy to spot, yet can cause frustrating calculation errors.

Space characters can cause formula errors.

After many years of working with Excel, I’ve become a Space Hunter. That sounds like a sci-fi movie title, but it’s just someone who can quickly locate and delete superfluous spaces in cell values.

Based on my space hunting experience, here are five techniques I use frequently to clean up data.

1. Find & Replace

The first method for space hunting is to use the Find & Replace feature.

After highlighting the cells that you want to search through, go to the Home tab. Then open the Find & Select dropdown menu. Select the Replace option. The keyboard shortcut for this is Ctrl + H.

Find and replace

That will bring up the Find and Replace window. On the Replace tab, place one blank space in the Find what field. Make sure there is nothing in the Replace with field. Hitting Replace All (keyboard shortcut: Alt+A) will remove any instances of a space in the data set that you selected.

Find and Replace all spaces

Although this method is really quick and easy, it’s only useful for data where you want ALL spaces removed. However, there are times when you want to keep spaces between words. For example, if your cells contain both first and last names, you will probably want to keep the space in between those names.

That scenario leads us to our second method for space hunting.

2. The TRIM Function

The TRIM function removes all spaces in a text string, except for single spaces between words.

Below is an example of a report where some of the cells look like they are indented but the indentation is actually just extra spaces. Let’s say we want to remove those spaces for uniformity’s sake. We can use the TRIM function to do that.

Remove extra spaces using the TRIM function

In a blank column, start by typing the equals sign (=) and the word TRIM, then tab into the TRIM function.

The only thing you need to identify for the TRIM function to work is the text that needs trimming. So either type the name of the cell or click on the cell that you want to trim and hit Enter. This will return the result you’re looking for: text with no spaces before or after it.

Trim function argument Text

When you copy the formula down for the whole column, the result looks like this.

TRIM function new column of data

As you can see, the spacing between the words remains in place, but any spacing before or after the text is removed.

With this method, we had to create a whole new column, so you would have to add the additional step of replacing the original column with the new one using Copy and Paste Values. You can then delete the column with the formulas.

3. Power Query

Like functions and formulas, queries can also be tripped up by the inclusion of a stray blank space.

Null values in Power Query caused by spaces

If you are unsure if blank spaces are what’s causing the problem, you can click into the Editor’s preview to see if there is a space or not.

Space after name shown in preview of power query editor

To remove the spaces, Power Query has a Trim feature found in the right-click menu. With the column that you want to fix selected, just right-click and choose Transform, and Trim.

Right click transform trim in power query

This trims all the blank space before/after the text string so that the query will return the correct values.

Tim data in order to return good values

If you are relatively new to Power Query, or could use a refresher, I recommend checking out my free webinar: The Modern Excel Blueprint.

Modern Excel Blueprint Training Webinar Excel Campus Jon Acampora

4. Macros and VBA

Let’s look at the same example we used for the TRIM function, but this time we will use a macro to trim extra spaces from text.

Start by opening the VB Editor. Go to the Developer tab and select the Visual Basic Button. The keyboard shortcut is Alt + F11.

Open the VB Editor with Alt+F11

I’ve written a simple macro that loops through each cell and replaces the value of the cell with the trimmed value. If you’d like to copy this macro, you can find it in the download file at the top of this post.

Macro to trim text

One of the benefits of using a macro is that you can assign it to a button. Here I’ve assigned it to a button on the actual worksheet.

Trim Macro Button on Worksheet

And here, I’ve added it to the ribbon by including this macro in my Personal Macro Workbook and assigning a button to it.

Custom Excel Ribbon Button for Trim Macro VBA

That way, I can use this macro on any workbook.

One downside to using the macro method for removing blank spaces is that you cannot undo the action once the macro has been run. In that case, it might be a good idea to save the file before running the macro, if you think you might need to un-trim the data for some reason.

It’s also important to note that the VBA Trim function does NOT trim extra blank spaces between words. Excel’s TRIM function will remove additional spaces between words. So if there are two spaces between the first and last name, TRIM will remove the additional space. VBA’s Trim will not do this. It only removes spaces from the beginning or end of the string. Thanks to Marvin (an Excel Campus Community Member) for bringing this to our attention!

Here are tutorials for how to create a Personal Macro Workbook as well as how to make Macro buttons, whether on the worksheet or in the ribbon.

How to Create a Personal Macro Workbook (Video Series)

How to Create Macro Buttons in Excel Worksheets

5. Trimming Other Characters

Sometimes after you have trimmed the spaces from your text, you might still get calculation errors. One reason for this could be that another hard-to-detect character might be in play. One such character is the non-breaking space. This is often used in HTML coding ( ) and is similar to a regular space, but would not be deleted by the TRIM function or our macro.

To determine which character might be gumming up the works, you can use the CODE function. By copying and pasting the invisible character into a blank cell, and then identifying that cell’s text in the CODE function (“text” is the only argument that needs to be identified for the CODE function), you will return a code number for that character. A quick Google search of that code number will reveal what type of character you are dealing with.

Code Function

In this case, the non-breaking space character is code 160.

One way to remove that character from your text would be to use Find & Replace. You can simply copy the character and paste it into the Find what field.

Find and replace non-breaking space

You could also use the REPLACE function to do the same thing.

One other option, since we know we want to remove the last character in the text, would be to use the LEFT and LEN functions to essentially create a customized trim feature.

LEFT returns the leftmost characters in a cell, up to a designated amount. LEN (short for Length) returns the number of characters in a cell.

So combining those two functions and subtracting 1 from the LEN to remove that unwanted character would leave just the text without the additional character.

LEFT and LENGTH functions to remove unwanted end character

Conclusion

I hope this has been helpful for you. I also explain how spaces can cause errors in formulas in my video on an Introduction to VLOOKUP.

There are actually more than just five ways to go about this task, and if you’d like to add to the list, please leave a comment below. As always, you can ask questions there as well.

Thanks for following along. Until next time!

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
  • Remove Spaces in Excel
    • Top 5 Methods to Remove Spaces in Excel
    • #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
    • Frequently Asked Questions
    • Recommended Articles

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.

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

#1 – TRIM Function

The TRIM functionThe Trim function in Excel does exactly what its name implies: it trims some part of any string. The function of this formula is to remove any space in a given string. It does not remove a single space between two words, but it does remove any other unwanted spaces.read more removes all spaces from a text string except for the single space between the words.

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.

Removing space Example 1

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

Removing space Example 1-1

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 text to columnsText to columns in excel is used to separate text in different columns based on some delimited or fixed width. This is done either by using a delimiter such as a comma, space or hyphen, or using fixed defined width to separate a text in the adjacent columns.read more wizard helps remove spaces in excel by splitting the data strings into separate columns. It works on cells containing numerical and textual values.

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.

Removing space Example 2

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.

Removing space Example 2-1

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

Removing space Example 2-2

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

Removing space Example 2-3

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.

Removing space Example 2-4

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

Removing space Example 3

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.

Removing space Example 3-1

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

Removing space Example 3-2

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

Removing space Example 3-3

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.

Removing space Example 3-4

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

#4 – Find and Replace Option

The 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 option helps remove spaces from numerical and textual data in Excel.

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

Find & Replace - Example 4

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

Find & Replace - Example 4-1

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

Find & Replace - Example 4-2

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

Find & Replace - Example 4-3

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

Find & Replace - Example 4-4

#5 – SUBSTITUTE Function

The SUBSTITUTE functionSubstitute 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 helps remove the spaces by replacing them with the existing data string.

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

Substitute Function- Example 5

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.

Substitute Function - Example 5-1

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

Substitute Function - Example 5-2

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.

Substitute Function - Example 5-3

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

Substitute Function - Example 5-4

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

Substitute Function - Example 5-5

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

Substitute Function - Example 5-6

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

What does it mean to remove spaces in excel and why is it important?

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.

How to remove the leading and trailing spaces in Excel with the TRIM function?

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:

“TRIM(text)”

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).”

How to remove all the spaces in Excel?

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

“=SUBSTITUTE(C2,“ ”,“”)”

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 –

  • Randomize List ExcelRandomizing a list in excel means selecting a random value from the data, to randomize a whole list in excel. There are two excel formulae for this: the =RAND() function, which returns any random value to the cell and then allows us to sort the list, and the =RANDBETWEEN() function, which returns random values to the cell from a number range specified by the user.read more
  • Hiding an Excel ColumnThe methods to hide columns in excel are — hide columns using right-click option, hide columns using shortcut cut key, hide columns using column width, hide columns using VBA code.read more
  • Hide Formula in ExcelHiding formula in excel is used when we do not want the formula to be displayed in the formula bar when we click on a cell with formulas. We can format the cells, check the hidden checkbox, and protect the worksheet.read more
  • Copy Sheet in ExcelThere are various ways to Copy or Move Sheets in Excel 1- By using the dragging method. 2 — By using the right-click method. 3 — Copy a sheet by using Excel Ribbon. 4- Copy Sheet from Another Workbook. and 5- Copy Multiple Sheets in Excel.read more

The space character for an Excel user can be a real problem. When exporting data from various IT systems, that export will often include extra spaces around values. Finding a way to remove spaces in Excel is a crucial skill for every user.

We often can’t see the space characters, but Excel sees them. They can be leading or trailing spaces which are at the start or end of the text string, but we can also find multiple spaces between words. These spaces cause values not to match and calculation errors to occur, which for an Excel user is almost the worst thing that can happen.

In this post, we will discover how to find and remove additional spaces in Excel so our data can be clean and usable.

The example data for this post is:

In the example data, we can see a lot of trailing, leading, and multiple spaces.

Watch the video

Watch the video on YouTube

We can use simple Excel functionality to remove additional spaces, such as Find and Replace or Flash Fill. These are fast and quick methods but need to be repeated if data changes. Therefore, they are great for one-off activities.

Find and Replace (#1)

Find and replace may seem obvious, but you would be surprised about the number of people who don’t think about it.

If our data contains leading, trailing, or mid-spaces that all need to be removed, the Find and Replace method is perfect.

In our example data, we have an issue with the Part Number column; it contains lots of rogue spaces.

  1. Select the range of cells to be changed (Cells B3-B10 in our example)
  2. Click Home > Find & Replace (dropdown) > Replace… (Shortcut: Ctrl + H)
  3. In the Find and Replace dialog box, enter a space into the find what field, and leave the replace with field blank.
  4. Click replace all
    Find and replace spaces

Ta-dah! Simple.

Part Numbers corrected with Find and Replace

Obviously, if our data should contain single spaces, such as a supplier name, this approach won’t work.

If our data contains double spaces that need to be removed, in the Find & Replace dialog box enter the following:

  • Find what: [enter two spaces]
  • Replace with: [enter a single space]

Repeat these steps multiple times until there are no more items to replace.

Flash Fill (#2)

Flash Fill was introduced in Excel 2013. It is easy to use and ideal for finding patterns in text strings. It’s a feature that runs in the background and makes recommendations at suitable points. So, you may have used Flash Fill before without knowing it.

With our data on the left, we can type how the first value should display. Then, when we start typing a second value, hopefully, Flash Fill will spring into action and make suggestions.

Flash Fill running automatically when entering data

If you are happy with the recommendations, press the Tab key to accept them. However, in our example, you will notice the period between Spares and com has been removed. We need to keep adding more examples for Flash Fill to use.

Once we have entered more values:

  1. Select the range of cells to be filled
  2. Click Data > Flash Fill
    Data Flash Fill from Ribbon

Done! Because we rely on Excel’s algorithm, we should check the other values to ensure they are right. In the screenshot below, column F shows the clean data.

Clean Data after Flish Fill

Flash Fill is a pretty nice feature.

Note: If Excel cannot find a matching pattern, it will return an error message.

Flash Fill Error

Functions

If we are looking for a more dynamic method of removing unnecessary spaces, then functions such as TRIM or SUBSTITUTE may be a better solution.

Formulas are useful if we are likely to get new data and have to perform the space removal process again. We simply apply the formula to the new data and it recalculates automatically.

TRIM Function to remove excess spaces (#3)

The TRIM function performs two tasks:

  • Removes leading and trailing spaces
  • Reduces multiple spaces to a single space

The TRIM function has a single argument, which is the text from which to remove spaces.

Let’s head back and see how we can use this with our Supplier name column.

TRIM Function to remove spaces

The formula in Cell F3 is

=TRIM(C3)

The result is that the spaces have been removed. It’s a simple and powerful function.

Once calculated, if we want, can copy the values in cells F3:F10 and paste the values into cells C3:C10. Alternatively, we could retain the calculation to handle any future data changes.

NOTE: The VBA and Power Query versions of trim are different. They do not remove additional spaces from the middle of strings.

SUBSTITUTE Function to replace spaces (#4)

If you want to combine the result of Find & Replace with the benefit of a function, then SUBSTITUTE is the way to go for you.

The SUBSTITUTE function replaces specific characters in a text string.

Syntax:

SUBSTITUTE(text, old_text, new_text, [instance_num])

Arguments:

  • Text: The text containing the characters to be substituted
  • Old_text: The text to replace
  • New_text: The text to replace the old_text with
  • Instance_num: Optional. Specifies which occurrence of old_text should be replaced. e.g. if 2 then only the second instance of old_text is substituted. If excluded, all instances of old_text are replaced.

Let’s apply SUBSTITUTE to our example data:

SUBSTITUTE to remove all spaces

The formula in Cell F3 is:

=SUBSTITUTE(B3," ","")

SUBSTITUTE is using Cell B3 and replacing all spaces with an empty text string.

Advanced methods

Depending on your specific scenario and experience, you may be using more advanced Excel features, such as Power Query, VBA Macros, or Office Scripts.

As these are more advanced features, we will not go through these step-by-step. If you’re using these already, you can apply your existing knowledge to apply the techniques.

Power Query (#5)

Power Query is Excel’s tool for cleaning dirty data. However, it is as easy as using the methods above.

Trim the leading and trailing spaces

To remove the leading and trailing spaces, select the column to be cleaned and click Transform > Format (dropdown) > Trim from the Ribbon.

Transform Format Trim

The leading and trailing spaces are removed instantly.

Remove double spaces within text

Unfortunately, the Power Query version of trim does not remove double spaces inside a text string. So, if this is your scenario, we need to turn to a more advanced technique.

The following custom function can be used to remove spaces. Enter the function into a blank query using the Advanced Editor.

(textValue as text)=>

let
    SplitText = Text.Split(textValue," "),
    ListNonBlankValues = List.Select(SplitText, each _<> ""),
    TextJoinList = Text.Combine(ListNonBlankValues," ")
in
    TextJoinList

I have named this query fxTrim.

To apply this function, click Add Column > Custom Column

In the Custom Column window, we can use the custom function.

Apply custom function to remove spaces

The formula used above is:

=fxTrim([Supplier])

After using the function, double spaces are removed. Once the data is clean, load it back into Excel.

NOTE: For a more advanced method to remove spaces in Power Query, check out this post: Remove excess spaces in Power Query

VBA Macro (#6)

If we remove spaces regularly, having a macro saved within our Personal Macro Workbook may be a quick and easy method.

VBA Trim: remove leading & trailing spaces

The following code removes leading & trailing spaces, but not double spaces from within a text string.

Sub RemoveLeadingTrailingSpaces()

Dim c As Range

'Loop through each cell in selection
For Each c In Selection

    'Apply VBA Trim function to each cell
    c = Trim(c)

Next c

End Sub

Excel Trim: remove leading, trailing, and double spaces

The following code will replicate Excel’s TRIM function.

Sub RemoveAdditionalSpaces()

Dim c As Range

'Loop through each cell in selection
For Each c In Selection

    'Apply Excel TRIM function to each cell
    c = Application.WorksheetFunction.Trim(c)

Next c

End Sub

VBA Replace: Remove all spaces

The following code removes all spaces.

Sub RemoveAllSpaces()

Dim c As Range

'Loop through each cell in selection
For Each c In Selection

    'Apply VBA Replace function to remove spaces
    c = Replace(c, " ", "")

Next c

End Sub

Office Scripts (#7)

If you are using Excel Online and have Office Scripts available, then you can use the following scripts:

Trim leading & trailing spaces

The following script removes leading & trailing spaces.

function main(workbook: ExcelScript.Workbook) {

//Declare and assign variable for the selected cells
let rng = workbook.getSelectedRange();

//Create array for the values in the range
let arr = rng.getValues();

//Loop through each item in the 2D array
for (let i = 0; i < arr.length; i++) {
  for (let j = 0; j < arr[0].length; j++) {

    //Apply JavaScript Trim function to each cell
    arr[i][j] = arr[i][j].toString().trim();

  }
}

//Push array back to cells using the setValues method
rng.setValues(arr);

};

Trim leading, trailing, and double spaces

The following script replicates the outcome of Excel’s TRIM function.

function main(workbook: ExcelScript.Workbook) {

//Declare and assign variable for the selected cells
let rng = workbook.getSelectedRange();

//Create array for the values in the range
let arr = rng.getValues();

//Loop through each item in the 2D array
for (let i = 0; i < arr.length; i++) {
  for (let j = 0; j < arr[0].length; j++) {

    //Apply RegEx to remove additional spaces function to each cell
    arr[i][j] = arr[i][j].toString().replace(/s+/g, ' ').trim();

  }
}

//Push array back to cells using the setValues method
rng.setValues(arr);

};

Remove all spaces

The following script removes all spaces.

function main(workbook: ExcelScript.Workbook) {

//Declare and assign variable for the selected cells
let rng = workbook.getSelectedRange();

//Create array for the values in the range
let arr = rng.getValues();

//Loop through each item in the 2D array
for (let i = 0; i < arr.length; i++) {
  for (let j = 0; j < arr[0].length; j++) {

    //Apply JavaScript Replace function to remove all spaces
    arr[i][j] = arr[i][j].toString().replace(/s/g,'');

  }
}

//Push array back to cells using the setValues method
rng.setValues(arr);

};

Conclusion

So, there you go, 7 ways to remove spaces in excel.

Many would say that we only need one way to achieve this; however, context is everything. Why use a Power Query method if Find and Replace will work? But if you’re using Power Query to extract data, then the Find and Replace method would be useless. So, the choice is entirely dependent on your situation.

Hopefully, this post has provided you with enough ways to remove spaces in Excel, no matter your scenario.


Headshot Round

About the author

Hey, I’m Mark, and I run Excel Off The Grid.

My parents tell me that at the age of 7 I declared I was going to become a qualified accountant. I was either psychic or had no imagination, as that is exactly what happened. However, it wasn’t until I was 35 that my journey really began.

In 2015, I started a new job, for which I was regularly working after 10pm. As a result, I rarely saw my children during the week. So, I started searching for the secrets to automating Excel. I discovered that by building a small number of simple tools, I could combine them together in different ways to automate nearly all my regular tasks. This meant I could work less hours (and I got pay raises!). Today, I teach these techniques to other professionals in our training program so they too can spend less time at work (and more time with their children and doing the things they love).


Do you need help adapting this post to your needs?

I’m guessing the examples in this post don’t exactly match your situation. We all use Excel differently, so it’s impossible to write a post that will meet everybody’s needs. By taking the time to understand the techniques and principles in this post (and elsewhere on this site), you should be able to adapt it to your needs.

But, if you’re still struggling you should:

  1. Read other blogs, or watch YouTube videos on the same topic. You will benefit much more by discovering your own solutions.
  2. Ask the ‘Excel Ninja’ in your office. It’s amazing what things other people know.
  3. Ask a question in a forum like Mr Excel, or the Microsoft Answers Community. Remember, the people on these forums are generally giving their time for free. So take care to craft your question, make sure it’s clear and concise.  List all the things you’ve tried, and provide screenshots, code segments and example workbooks.
  4. Use Excel Rescue, who are my consultancy partner. They help by providing solutions to smaller Excel problems.

What next?
Don’t go yet, there is plenty more to learn on Excel Off The Grid.  Check out the latest posts:

Remove Spaces in Excel

Excel Remove Spaces (Table of Contents)

  • Introduction to Remove Spaces in Excel
  • Different Types Of Spaces
  • How to Remove Extra Spaces in Excel?

Introduction to Remove Spaces in Excel

There are multiple ways to remove spaces in excel. The first way we can remove the extra unwanted spaces with the help of the FIND and REPLACE option (Ctrl + H). There we need to put a space and replace that with Blank (Nothing kept). This removes the spaces anywhere from the selected cells. In another way, we can remove the spaces by using a TRIM function. This removes the spaces which are there at the start and end of the selected cell content. And we can also use the SUBSTITUTE function, where we can substitute space with blank to remove spaces completely.

Different Types Of Spaces

  • It may contain extra spaces before text strings in cells; these spaces are called Leading spaces.

Leading Space

  • It may contain extra spaces after text strings in cells; these spaces are called Trailing spaces.

Trailing space

  • Datasets may contain extra in-between spaces, i.e.additional spaces in between text.

Extra in-between space

  • Datasets may also contain Line breaks with extra space.

Line breaks with extra space

We can get rid of these types of spaces quickly & easily with the below-mentioned options:

  • FIND AND REPLACE
  • TRIM Function
  • SUBSTITUTE Function
  • CLEAN and TRIM function to Remove Extra Space of Line Break in excel

TRIM Function

TRIM function is a prebuilt integrated function categorized under Text functions. It Removes all extra spaces from text except a single space between words in excel.

The syntax or formula for the TRIM function in Excel is:

TRIM Formula

Trim function in Excel has only one compulsory argument or parameter, i.e. text.

  • Text: It is cell content from where you need to remove extra spaces in excel.

The TRIM function only removes the ASCII space character (32) from the text.

How to Remove Extra Spaces in Excel?

Remove extra spaces in Excel is very simple and easy. Let’s understand the working of removing extra spaces in excel with the help of some examples.

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

Example #1 – Remove Excel Spaces with the help of Find and Replace

In the below-mentioned example, I have a dataset in column D that contains all three types of extra spaces, i.e. Leading spaces, Trailing spaces & Extra in-between spaces.

For reference, I have done a number of character count for the column D datasets. With the help of the LEN function in column E., I have taken this raw data to another new column (column H) to apply the Find and Replace task.

Example 1

Now, I have to select the cell range where the Find and Replace parameter needs to be applied to remove extra spaces in excel.

Remove Spaces Example 1-2

Now, to activate the find and replace option, press the shortcut key Ctrl + H, find and replace window appears.

Remove Spaces Example 1-3

In Find what: input bar, insert a blank space with the help of the space bar once, and in Replace with no need to input anything, it should remain blank. Click on the Replace All button.

Remove Spaces Example 1-4

It replaces all the blank spaces in the cell.

Remove Spaces Example 1-5

You can find a difference in character count between both datasets. Where Find and Replace remove all the blank spaces. In extra in-between spaces content also, it has removed all the blank spaces without retaining a single space between words (This can be rectified with the help of TRIM function).

Result of Example 1

Note: This method is only used when you want to remove a leading & trailing type of extra spaces from selected cells or to remove all the spaces in the data range from excel completely.

Example #2 – Remove Excel Spaces with the help of TRIM Function

In the below-mentioned example, I have a dataset in column D that contains all three types of extra spaces, i.e. leading spaces, trailing spaces & extra in-between spaces.

For reference, I have done a number of character count for the column D datasets. With the help of the LEN function in column E., I have taken this raw data to another new column (column G) to apply the TRIM Function. The Excel TRIM function removes all spaces from text except a single space between words.

Example 2

Now, In cell H4, let’s apply a TRIM function.

Remove Spaces Example 2-2

In the Formulas tab, click the Text drop-down menu in the Functions section and select TRIM.

Remove Spaces Example 2-3

Now the function argument dialog box appears, click on the cell G4, which contains the text where I would like to remove spaces to complete the function, then click on OK.

Remove Spaces Example 2-4

Now, you can observe in cell H4, where trim function removes leading space in that cell.

Remove Spaces Example 2-5

Similarly, a TRIM function is applied to other range by selecting the cell H4 and drag it to H9 and click Ctrl+D to apply to the rest of the cells.

Remove Spaces Example 2-6

You can find a difference in character count between both datasets where TRIM Function removes all spaces before and after the text in the cell (i.e. G4, G5, G6 & G7) & consecutive spaces in the middle of a string in the cell G8 & G9.

Result of Example 2

Example #3 – Remove Excel Spaces with the help of SUBSTITUTE Function

It will remove all the extra excel spaces, including single spaces between words or numbers.

In the below-mentioned example, I have a dataset in column D that contains all three types of extra spaces, i.e. leading spaces, trailing spaces & extra in-between spaces.

For a reference purpose, I have done a number of character count for the column D datasets. With the help of the LEN function in column E., I have taken this raw data to another new column (column G) to apply the SUBSTITUTE Function.

Example 3

Now, In cell H4, let’s apply the SUBSTITUTE Function.

Remove Spaces Example 3-2

In a Formulas tab, click the Text drop-down menu in the Functions section and select SUBSTITUTE.

Remove Spaces Example 3-3

Now the function argument dialog box appears:

  • Text Click on the first cell in the column that you need to be changed.
  • In the Old_text, I need to enter the character that needs to be replaced; it should be entered between double-quotes. i.e. for removal of spaces, it will be ” “.
  • Here, in the New text, I don’t want to replace anything; therefore, it is typed as “”.

Remove Spaces Example 3-4

Now, you can observe in cell H4, where the Substitute function removes leading space in that cell.

Remove Spaces Example 3-5

SUBSTITUTE Function is applied to other ranges by selecting the cell H4 and drag it till H9 and click Ctrl+D so that it is applied to other cells.

Remove Spaces Example 3-6

You can find a difference in character count between both datasets. Substitute Function removes all the blank spaces; in extra in-between spaces content, it has removed all the blank spaces without retaining a single space between words.

Result of Example 3

Things to Remember about Excel Remove Spaces

  • Since the extra space is also a character, therefore in ASCII (American Standard Code for Information Interchange) encoding, it has code number 32.
  • Sometimes, the data appears as line breaks which may contain extra spaces between words; To remove those extra space, we can combine Excel TRIM and CLEAN function to Remove the Extra Space of Line Break.

Recommended Articles

This has been a guide to Remove Spaces in Excel. Here we discuss how to Remove Extra Spaces in Excel along with practical examples and a downloadable excel template. You can also go through our other suggested articles –

  1. Address Excel Function
  2. SUBSTITUTE Function in Excel
  3. LEN Function in Excel
  4. Excel SEARCH Function

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

Maintenance Alert: Saturday, April 15th, 7:00pm-9:00pm CT. During this time, the shopping cart and information requests will be unavailable.

Categories: Advanced Excel
Tags: Excel Formula Remove Spaces

Does this sound familiar? You are searching for data that you know you’ve entered, but a query for Joe Smith simply doesn’t return any results. Or, how about – you are trying to add up two columns of numbers, but you keep getting errors.

Often, these issues are caused by extra spaces hiding before, after or between the text and numbers in your data. Especially when information has been copy/pasted into a spreadsheet, extra spaces can come along for the ride and lurk unnoticed until something goes wrong.

Excel offers several ways to help you remove spaces and clean up your data, but you will want to choose the right technique for the type of data you are working with. The following tips will describe two methods using functions and formulas to remove unwanted spaces from your data.

These steps will apply to Excel 2007-2013. Images were taken using Excel 2013 on the Windows 7 OS.

Option 1

Use the Trim Function

The TRIM function removes all spaces from text except a single space between words. Use this function when you have text data that contains hidden spaces in the cell. In our example, you’ll see that there are multiple “Joe Smiths” in our data. At a glance, several of them even look the same. However, the # of Characters column reveals that there are hidden spaces buried in the text.

Step 1

To use the TRIM function, you will need to create a temporary, or helper, column for the corrected data at the end of your spreadsheet. For the purposes of this demonstration, we’ve called the column “Trim.”

Fred Pryor Seminars_Excel Formula Remove Spaces_1

To follow using our example above, download Excel Remove Spaces Formula Template

Step 2

Click in the first cell of the Trim column. On the Formulas tab, click the Text dropdown menu in the Functions group and select TRIM.

Fred Pryor Seminars_Excel Formula Remove Spaces_2

Step 3

After the dialog box appears, click on the cell that contains the text you would like to remove spaces from to complete the function. Click OK.

Fred Pryor Seminars_Excel Formula Remove Spaces_3

Step 4

Copy the function to the remaining cells in the column to apply the function to the rest of the Name cells. You can see that the TRIM function cleaned up the extra spaces and the character counts are now all the same except for the “JoeSmith” that did not have any spaces between the first and last name. Note that TRIM will not ADD spaces.

Fred Pryor Seminars_Excel Formula Remove Spaces_4

Step 5

Now you just need to replace your original data with your clean data. To do this, select all of the cells in the Trim column, then hit CTRL+C to copy the cells to the clipboard.

Then, select the first cell in the Name column and right-click. Select Paste Values under the Paste Options heading. Now you can Delete the Trim helper column and your Name column is clean.

Fred Pryor Seminars_Excel Formula Remove Spaces_5

Option 2

Use a Formula to Remove All Spaces

If you need to prepare your data for import into a database (such as MS Access) or have a combination of number and text data that simply needs ALL spaces removed, you can use a formula instead of the TRIM function to remove ALL blanks in a cell.

Step 1

Create a temporary, or helper, column for the corrected data at the end of your spreadsheet like you did for the TRIM function. In this example the column is called No Spaces.

Fred Pryor Seminars_Excel Formula Remove Spaces_6

Step 2

Click in the first cell of the Trim column. On the Formulas tab, click the Text dropdown menu in the Functions group and select SUBSTITUTE.

Fred Pryor Seminars_Excel Formula Remove Spaces_7

Step 3

When the dialog box appears:

  • Click on the first cell in the column that you need changed
  • In the “Old_text” field, enter the character you want replaced separated by quotes. To remove spaces this would then be ” “.
  • In the “New_text” field, enter the character you want to appear instead. Since we want NO characters to replace the space, type “”.

Step 4

Click OK to apply the formula to the cell.

Fred Pryor Seminars_Excel Formula Remove Spaces_8

Step 5

Copy the formula to the remaining cells in the helper column. Then copy the data to the data column as you did before using CTRL-C and Paste Options.

Fred Pryor Seminars_Excel Formula Remove Spaces_9

Bonus Hint!

You can also remove spaces using the Find/Replace feature in Excel. Click CTRL+F to open the Find dialog box, then click the Replace tab. Enter one space ” ” in the Find what: field and leave the Replace with: field empty to remove all spaces.

Warning: This technique will search for and replace ALL spaces in the entire sheet or selection area. Use carefully so that you don’t remove spaces you still want or need!

Fred Pryor Seminars_Excel Formula Remove Spaces_10

With these tips, you can clean up data entered from multiple sources and ensure that it is consistent and less prone to unintended duplication. Use these tips to remove spaces when you want to:

  • Find unintended duplicates in your data
  • Prepare someone else’s data before you import it into your own spreadsheets
  • Prepare your data for export into a database

When do you find the need to find and remove unwanted spaces?

PRYOR+ 7-DAYS OF FREE TRAINING


Courses in Customer Service, Excel, HR, Leadership,
OSHA and more. No credit card. No commitment. Individuals and teams.

(Note: This guide on how to remove spaces in Excel is suitable for all Excel versions including Office 365)

Dealing with large data in Excel can be quite difficult. Especially, when you copy or import huge data from any database, dealing with them can be a bit complicated. Sometimes, various functions and formulae might be needed to operate the values. 

One such example is unwanted spaces. Extra Spaces can be hard to deal with. Since extra spaces are also counted as characters, they can be a menace when you want to search through the huge data. In the case of numbers, some functions throw an error because space is treated as an additional character.

The spaces can be leading, trailing, or occurring in between words or numbers. Sometimes, extra spaces appear along with some unprintable characters.

Leading spaces and the spaces in-between values can be seen with a naked eye, but they too can be difficult to spot when you’re dealing with large data. Trailing spaces cannot be easily found. So, how do you remove these extra spaces? 

Don’t worry. In this guide, I will tell you 3 easy ways to remove spaces in Excel.

You’ll Learn:

  • How to Remove Spaces in Excel Using TRIM Function?
  • How to Remove Spaces in Excel Using Find and Replace?
  • How to Remove Spaces in ExcelUsing SUBSTITUTE Function?

Watch this short video on How to Remove Spaces in Excel

Related:

The Excel SMALL Function – 3 Best Examples

How to Make An Excel Forecast Sheet in 3 Steps – The Best Guide

How to Use Excel COUNTIFS: The Best Guide

1. How to Remove Spaces in Excel Using TRIM Function?

Excel has a lot of functions and formulas to help you perform certain operations. 

To remove unwanted spaces between texts you can use the TRIM function.

This function removes the excess leading, trailing, and spaces in-between values. However, there will exist a space that separates the two texts. You will need an empty column for the trimmed values. 

Consider an example that contains different combinations of leading, trailing, and spaces in-between.

To trim the extra spaces for the values, enter the function =TRIM(cell_number) in the destination cell or the formula bar. Here, cell_number denotes the place of the untrimmed text. 

Remove spaces in Excel using TRIM function
Remove spaces in Excel using TRIM function

In the above example, the untrimmed value lies in cell A3, so enter the formula =TRIM(A3) in the destination cell or the formula bar.  

This gives you the trimmed value without any leading, in-between, or trailing spaces.

Use the drag handle to apply the formula to other existing cells with untrimmed spaces.

Use the drag handle to add formula to other cells
Use the drag handle to add formula to other cells

This creates the trimmed values onto the helper column. You can replace the untrimmed values by copying and pasting the trimmed values to the destination.

Copy the trimmed values by right-clicking on the selected column and selecting cut/copy. While pasting, use the paste special and paste the trimmed spaces as values.

Note: In some cases, along with spaces, there might be additional non-printable characters. The TRIM function only removes the spaces, the CLEAN function removes any non-printable characters in the text. By using a combination of them you can remove both the spaces and the non-printable characters.  

Remove spaces in Excel using TRIM and CLEAN function
Remove spaces in Excel using TRIM and CLEAN function

Also Read:

How to Add Error Bars in Excel? 7 Best Methods

How to Superscript in Excel? (9 Best Methods)

Excel Goal Seek—the Easiest Guide (3 Examples)

2. How to Remove Spaces in Excel Using Find and Replace?

This is another method to remove extra spaces between words or numbers. This method works on the principle of finding the number of spaces and replacing it. However, this method leaves one space with leading, trailing, or in-between space. This method is very effective when the untrimmed values are more spread out over the spreadsheet.

One advantage of this method is that it replaces the values in the same place. You don’t have to create an additional empty column for the trimmed values. 

To trim the values, select untrimmed values.

Select the contents with unwanted spaces
Select the contents with unwanted spaces

Navigate to Home > Editing > Find & Select, and click on Replace. Or, simply press Ctrl+H. This opens up a Find and Replace dialog box.

Remove spaces in Excel using Find and Replace
Remove spaces in Excel using Find and Replace

Enter double-space (“  “) in the Find what: text box and single space (“ “) in the Replace with: text box.

Click Replace All.

This pops up a notification showing replacements made for a certain number of places. Click OK.

Replacements made pop-up
Replacements made pop-up

Again, click on replace all until you get a “We couldn’t find anything to replace” notification shows up.

No more replacements pop-up
No more replacements pop-up

Note: This method is especially very useful when removing spaces from numbers.

In some cases, large numbers can be separated by spaces. When performing any functions or while searching for numbers, the spaces become an obstacle.

Removing space from numbers is similar to the method of removing spaces from text. 

Select the untrimmed values. Then, click on Ctrl + H.

The Find and Replace dialog box opens. Enter a single space (“ “) in the Find what: text box, and leave the Replace with: text box empty.

Remove spaces between numbers in Excel using Find and Replace
Remove spaces between numbers in Excel using Find and Replace

Click on Replace All. This gives you the number trimmed of all the spaces.

Spaces between numbers removed
Spaces between numbers removed

This method can also be used to remove all the spaces from texts.

3. How to Remove Spaces in Excel Using SUBSTITUTE Function?

If you want to remove all the spaces associated with numbers or text, this method is the go-to. By using a simple formula, you can remove all the spaces from your data.

This method works on the principle of replacing the space with an empty string.

To trim the values of unwanted spaces, enter the formula =SUBSTITUTE(A22,” “,””) in the destination cell or the formula bar. Here, A1 is the cell that contains the untrimmed values. That is, the space (“ “) is replaced by an empty string value (“”).

Remove spaces in Excel using SUBSTITUTE function
Remove spaces in Excel using the SUBSTITUTE function

Suggested Reads:

How to Shade Every Other Row in Excel? (5 Best Methods)

How to Extract an Excel Substring? – 6 Best Methods

How to Split Cells in Excel? 3 Easy Methods

Closing Thoughts

Removing unnecessary spaces helps you perform Excel functions and easily search through large data. This also makes your data look more pleasing to the eye.

In this article, we have seen 3 methods to remove leading, trailing, or spaces in-between. Each method has its advantages. Choose the method that suits your preference.

If you need more high-quality Excel guides, please check out our free Excel resources center.

Simon Sez IT has been teaching Excel for over ten years. For a low, monthly fee you can get access to 100+ IT training courses. Click here for advanced Excel courses with in-depth training modules.

Simon Calder

Chris “Simon” Calder was working as a Project Manager in IT for one of Los Angeles’ most prestigious cultural institutions, LACMA.He taught himself to use Microsoft Project from a giant textbook and hated every moment of it. Online learning was in its infancy then, but he spotted an opportunity and made an online MS Project course — the rest, as they say, is history!

Понравилась статья? Поделить с друзьями:
  • Delete rows in excel with vba
  • Delete rows from table word
  • Delete repeated words in word
  • Delete page number in word
  • Delete one row excel vba