# Excel Formula To Remove Spaces: Tips, Samples, And Faqs

Friday, April 7th 2023. | Excel Templates

## Introduction

Excel is an essential tool for many people, especially those who work with data. However, working with data can be frustrating when there are spaces between the characters. It can make it challenging to manipulate the data, and it can also affect the accuracy of the results. Fortunately, there are Excel formulas that can remove spaces, making it easier to work with data. In this article, we will discuss some Excel formulas to remove spaces, tips on how to use them, and answer some frequently asked questions.

## Samples of Excel Formula to Remove Spaces

### Sample 1: TRIM Function

The TRIM function in Excel is one of the most popular ways to remove spaces from data. It removes all spaces from the beginning and end of a string, leaving only a single space between words. The formula for the TRIM function is: =TRIM(text) Where “text” is the cell reference or text string that you want to remove spaces from. For example, if you have a cell with the text ” Hello World “, you can use the TRIM function to remove the spaces by typing: =TRIM(A1)

### Sample 2: SUBSTITUTE Function

The SUBSTITUTE function in Excel can also be used to remove spaces. It replaces one or more instances of a character with another character. In this case, we want to replace the space character with an empty string. The formula for the SUBSTITUTE function is: =SUBSTITUTE(text, old_text, new_text, [instance_num]) Where “text” is the cell reference or text string that you want to remove spaces from, “old_text” is the character that you want to replace (in this case, a space), “new_text” is the character that you want to replace it with (in this case, an empty string), and “instance_num” is optional and specifies which occurrence of the old_text you want to replace. For example, if you have a cell with the text “Hello World”, you can use the SUBSTITUTE function to remove the spaces by typing: =SUBSTITUTE(A1,” “,””)

### Sample 3: CLEAN Function

The CLEAN function in Excel removes all non-printable characters from a string, including spaces. It is useful when you have data that has been copied and pasted from other sources, and it contains hidden characters that you can’t see. The formula for the CLEAN function is: =CLEAN(text) Where “text” is the cell reference or text string that you want to remove spaces from. For example, if you have a cell with the text ” Hello World “, you can use the CLEAN function to remove the spaces by typing: =CLEAN(A1)

## Tips for Using Excel Formula to Remove Spaces

Here are some tips to help you use Excel formulas to remove spaces effectively: 1. Always make a backup copy of your data before applying any formulas. 2. Use the “Find and Replace” feature to check for spaces and replace them with a character that is not used in your data (e.g., an underscore). This will make it easier to apply formulas without accidentally removing spaces that are part of the data. 3. Be careful when using the SUBSTITUTE function. If you replace all spaces with an empty string, it will also remove spaces between words that are supposed to be there.

### 1. How do I remove spaces before or after a text string?

You can use the TRIM function to remove spaces before or after a text string. The TRIM function will remove all spaces from the beginning and end of a string, leaving only a single space between words. For example, if you have a cell with the text ” Hello World “, you can use the TRIM function to remove the spaces by typing: =TRIM(A1)

### 2. How do I remove all spaces from a text string?

You can use the SUBSTITUTE function to remove all spaces from a text string. The formula for the SUBSTITUTE function is: =SUBSTITUTE(text, ” “, “”) Where “text” is the cell reference or text string that you want to remove spaces from. For example, if you have a cell with the text ” Hello World “, you can use the SUBSTITUTE function to remove all spaces by typing: =SUBSTITUTE(A1,” “,””)

### 3. How do I remove spaces between words?

You can use the SUBSTITUTE function to remove spaces between words. However, you need to be careful not to remove spaces that are part of the data. For example, if you have a cell with the text “John Smith”, you can use the SUBSTITUTE function to remove the space between “John” and “Smith” by typing: =SUBSTITUTE(A1,” “,””)

### 4. How do I remove spaces from a range of cells?

You can use the same formulas to remove spaces from a range of cells. Simply select the range of cells that you want to apply the formula to and type the formula in the first cell of the selected range. Then press Enter and the formula will be applied to all the cells in the range.

### 5. How do I remove spaces from a specific position in a text string?

You can use the REPLACE function to remove spaces from a specific position in a text string. The formula for the REPLACE function is: =REPLACE(old_text, start_num, num_chars, new_text) Where “old_text” is the cell reference or text string that you want to remove spaces from, “start_num” is the position of the first character that you want to replace, “num_chars” is the number of characters that you want to replace, and “new_text” is the character that you want to replace it with (in this case, an empty string). For example, if you have a cell with the text “John Smith”, and you want to remove the space between “John” and “Smith”, you can use the REPLACE function by typing: =REPLACE(A1,5,1,””)

### 6. How do I remove spaces from the beginning of a text string?

You can use the TRIM function to remove spaces from the beginning of a text string. The TRIM function will remove all spaces from the beginning and end of a string, leaving only a single space between words. For example, if you have a cell with the text ” Hello World”, you can use the TRIM function to remove the spaces by typing: =TRIM(A1)

### 7. How do I remove spaces from the end of a text string?

You can use the TRIM function to remove spaces from the end of a text string. The TRIM function will remove all spaces from the beginning and end of a string, leaving only a single space between words. For example, if you have a cell with the text “Hello World “, you can use the TRIM function to remove the spaces by typing: =TRIM(A1)

## Tags

1. Excel formulas 2. Data manipulation 3. TRIM function 4. SUBSTITUTE function 5. CLEAN function 6. Find and Replace 7. Frequently Asked Questions (FAQ)

tags: , ,