Formula space 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

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

Click the “Data” tab in the ribbon, then look in the “Data Tools” group and click “Text to Columns.” The “Convert Text to Columns Wizard” will appear. In step 1 of the wizard, choose “Delimited” > Click [Next]. A delimiter is the symbol or space which separates the data you wish to split.

Contents

  • 1 How do I separate Data in Excel?
  • 2 Can space be a separator in Excel?
  • 3 How do I separate text in Excel formula?
  • 4 How do I separate text and space in Excel?
  • 5 How do I separate first space in Excel?
  • 6 How do I separate first and last names in Excel?
  • 7 Is there a way to separate names in Excel?
  • 8 How do I remove spaces before Text in Excel?
  • 9 How do you use concatenate?
  • 10 How do I copy a space separated in Excel?
  • 11 How do I extract Data from an Excel table based on criteria?
  • 12 How do I separate numbers and names in Excel?
  • 13 How do I separate columns in Excel?
  • 14 How do I separate names in sheets?
  • 15 How do I delete empty rows in Excel?
  • 16 Why is TRIM not removing spaces in Excel?
  • 17 What is the TRIM function in Excel?
  • 18 How do you CONCATENATE 3 columns in Excel?
  • 19 How do you combine 2 cells in Excel?
  • 20 What’s the difference between concat and CONCATENATE?

Try it!

  1. Select the cell or column that contains the text you want to split.
  2. Select Data > Text to Columns.
  3. In the Convert Text to Columns Wizard, select Delimited > Next.
  4. Select the Delimiters for your data.
  5. Select Next.
  6. Select the Destination in your worksheet which is where you want the split data to appear.

Can space be a separator in Excel?

Look for “Data” tab and “Text in column” button. In the step 1, select “Delimited“. In the step 2, select first “space”, and then choose “string classifier” as ” . Then Excel will recognise the string quoted in ” ” and separate in columns the data with space.

How do I separate text in Excel formula?

1st method
You can do so, click on the header ( A , B , C , etc.). Then click the little triangle and select “Insert 1 right”. Repeat to create a second free column. In the first free column, write =SPLIT(B1,”-“) , with B1 being the cell you want to split and – the character you want the cell to split on.

How do I separate text and space in Excel?

Select the text you wish to split, and then click on the Data menu > Split text to columns. Select the Space. Your text will be split into columns.

How do I separate first space in Excel?

Copy and paste the formula =LEFT(A2,FIND(” “,A2)-1) into the Formula Bar, and then press the Enter key. Drag the Fill Handle down to the cell range you want to split. Now the contents before the first space are all split out.

How do I separate first and last names in Excel?

Read the steps

  1. Add an empty column by right-clicking on the top of the column next to the existing column of names, then select Insert.
  2. Click the Data tab.
  3. Click on the top of the column with your contacts’ names to highlight the whole column.
  4. Click Text to Columns.
  5. Select “Delimited” and click Next.

Is there a way to separate names in Excel?

Split Names tool – fastest way to separate names in Excel
Select any cell containing a name you want to separate and click the Split Names icon on the Ablebits Data tab > Text group. Select the desired names parts (all of them in our case) at click Split.

How do I remove spaces before Text in Excel?

Trim Spaces for Excel – remove extra spaces in a click

  1. Select the cell(s) where you want to delete spaces.
  2. Click the Trim Spaces button on the ribbon.
  3. Choose one or all of the following options: Trim leading and trailing spaces. Trim extra spaces between words, except for a single space.
  4. Click Trim.

How do you use concatenate?

There are two ways to do this:

  1. Add double quotation marks with a space between them ” “. For example: =CONCATENATE(“Hello”, ” “, “World!”).
  2. Add a space after the Text argument. For example: =CONCATENATE(“Hello “, “World!”). The string “Hello ” has an extra space added.

How do I copy a space separated in Excel?

How to Copy Delimited Text to Excel

  1. Select the delimited text and copy it to the clipboard.
  2. Launch Excel and create a new workbook.
  3. Click the first cell in column A and click the “Paste” button in the ribbon.
  4. Click the column A header to select the entire column.
  5. Leave the Delimited option checked and click “Next.”

Filter Unique Records

  1. Select a cell in the database.
  2. On the Excel Ribbon’s Data tab, click Advanced.
  3. In the Advanced Filter dialog box, choose ‘Copy to another location’.
  4. For the List range, select the column(s) from which you want to extract the unique values.
  5. Leave the Criteria Range blank.

How do I separate numbers and names in Excel?

Split text and numbers

  1. Generic formula. =MIN(FIND({0,1,2,3,4,5,6,7,8,9},A1&”0123456789″))
  2. To separate text and numbers, you can use a formula based on the FIND function, the MIN function, and the LEN function with the LEFT or RIGHT function, depending on whether you want to extract the text or the number.
  3. Overview.

How do I separate columns in Excel?

Select the cell, range, or entire column that contains the text values that you want to split. On the Data tab, in the Data Tools group, click Text to Columns. Follow the instructions in the Convert Text to Columns Wizard to specify how you want to divide the text into separate columns.

How do I separate names in sheets?

Using Split Text into Columns Feature

  1. Select the cells that contain the name that you want to split.
  2. Click the Data tab.
  3. Click on ‘Split Text into Columns’ option.
  4. In the Separator box that appears, select Space as the delimiter.

How do I delete empty rows in Excel?

Easy Ways to Remove Blank or Empty Rows in Excel

  1. Select the row. Click its heading or select a cell in the row and press Shift + spacebar.
  2. Right-click the selected row heading. A drop-down menu appears.
  3. Select Delete.

Why is TRIM not removing spaces in Excel?

One space character commonly used in Web pages that TRIM() will not remove is the non-breaking space. If you have imported or copied data from Web pages you may not be able to remove the extra spaces with the TRIM() function if they are created by non-breaking spaces.

What is the TRIM function in Excel?

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.

How do you CONCATENATE 3 columns in Excel?

How to Combine Three Columns in Excel

  1. Open your spreadsheet.
  2. Select the cell where you want to display the combined data.
  3. Type =CONCATENATE(AA, BB, CC) but insert your cell locations.
  4. Adjust the formula to include any needed spaces or punctuation.

How do you combine 2 cells in Excel?

Combine text from two or more cells into one cell

  1. Select the cell where you want to put the combined data.
  2. Type = and select the first cell you want to combine.
  3. Type & and use quotation marks with a space enclosed.
  4. Select the next cell you want to combine and press enter. An example formula might be =A2&” “&B2.

What’s the difference between concat and CONCATENATE?

The CONCAT function combines the text from multiple ranges and/or strings, but it doesn’t provide delimiter or IgnoreEmpty arguments. CONCAT replaces the CONCATENATE function. However, the CONCATENATE function will stay available for compatibility with earlier versions of Excel.

Abstract

Many times, data is entered into Excel workbooks with spaces. These unwanted spaces might be at the beginning of the data or at the end or even sometimes in between strings. So, the thing is how to remove spaces in Excel?

These spaces can cause issues when you try to analyze the data and create reports out of it. The following options will help you remove spaces in Excel sheets.

Remove extra spaces in Excel through the GUI

Level of difficulty: LOW

Find and Replace:

This option helps you to remove spaces in Excel’s single sheet or you may remove spaces from all sheets in your workbook. This option will help you to remove leading spaces, trailing spaces, and even spaces in between strings. You also have the option to remove spaces from a selected range. The following steps will help you use Excel’s find and replace option to remove spaces through the GUI.

Step 1: Select the range from which you want to remove extra spaces in Excel.

Step 2: From the Home header in the Excel ribbon, select “Editing”. Then click on “Find & Select” and choose “Replace”. If you are comfortable in using keyboard shortcuts, press “Ctrl + H” to open the Find & Replace wizard.

Step 3: On the wizard, under the tab “Header” you will see two text boxes. The first text box is “Find What:” and the second text box is the “Replace with:” field. In the “Find What:” text box type a space and leave the “Replace with:” with a NULL value.

Step 4: The wizard will also have 3-drop downs. The first drop-down allows the user to do the find and replace within the sheet or at the workbook level. The second drop-down makes the search at Row level or at the column level. The third drop-down makes Excel search on formulas or on values.

Step 5: Click on “Replace All” to remove all spaces from your data.

How to Remove spaces in Excel through Formula

Level of difficulty: LOW

TRIM

This inbuilt excel function helps you to remove leading and trailing spaces from your Excel data. However, this will not remove spaces between strings. The only drawback with this option is, you must type and apply the formula in a separate cell, then copy it and using ‘paste special’ to paste it as value.

Step 1: Use an existing empty column or create a new column and start typing the formula = TRIM (CELL_ADDRESS). Please note that you have to update the CELL_ADDRESS in this formula with the actual address of the starting cell in your Excel range.

Step 2: Press enter to see the leading and trailing spaces being removed from the data in the selected cell.

Step 3: Select the cell in which you typed the formula. Click and drag the bottom-right corner of it until you reach the last cell in the excel range.

Step 4: The new column will now contain the same data from the selected range. However, this will not contain the leading and trailing spaces. This new column will still contain the formulas within it. We should remove the formulas without affecting the displayed data.

Step 5: Select all cells in this new column, copy them, and then using ‘paste special’ paste the values. You can paste data directly on your original column or into a new column.

SUBSTITUTE

This inbuilt excel function helps you to remove leading space, trailing space, and spaces between your Excel data. As the name implies, this function substitutes space with the replacing character that you input in the formula. The syntax is = SUBSTITUTE (Text, Old text, New Text)

As shown below, for the first parameter, you can pass a string or you can pass a CELL address. In the place of Old text, you have to mention an empty space and in the place of New Text, you can pass a NULL value.

= SUBSTITUTE (A2,” “,””)

How To Remove Spaces In Excel 1

Remove spaces using user define a function

Level of difficulty: MEDIUM

TRIM clears both leading and trailing spaces. Nevertheless, it does not allow you to clear either the leading space or the trailing space. However, you can achieve this using user-defined function. To build your custom functions, you would be using the function LTRIM and RTRIM, which is available only with VBA. LTRIM removes the leading space and RTIM removes trailing spaces in Excel sheet.

Step 1: If you are on worksheets, press Alt+F11 to open the VBA editor.

Step 2: Right-click on the VBA project at the left, select the option ‘Insert’ and then click “Module”. This will insert a new module into your VBA project.

Step 3: Copy these scripts into your module and save your workbook as a macro-enabled file. The first script will create a new user-defined function with which you can remove leading spaces from a string. The second script will create a new user-defined function with which you can remove trailing spaces in Excel.How To Remove Spaces In Excel 2

Step 4: You can now use these user-defined functions in your Worksheet formulas or in your VBA scripts.

Step 5: Below is an example for using this user-defined function in the Worksheet formula.

This will remove leading space from the Cell A2;

Please note that our guide applies to Excel 2016 and might vary across versions of Excel.

Понравилась статья? Поделить с друзьями:
  • Formula not showing in excel
  • Forms of the word worse
  • Formula in word field
  • Forms of the word weight
  • Formula in microsoft word