Remove Spaces Between Words in Excel: 3 Easy Methods
In this article
To remove spaces between words in Excel, the fastest method is using the Find and Replace tool: press Ctrl + H, type a single space in the "Find what" box, leave the "Replace with" box empty, and click "Replace All." This instantly strips every space from the selected cells. Depending on your goal—whether you want to remove every single space, only extra spaces, or create a dynamic formula that updates automatically—different tools are required. This guide covers the three most effective ways to handle whitespace in your spreadsheets.
What You'll Need
- A computer with Microsoft Excel installed (works on Windows and macOS).
- A dataset containing text with unwanted spaces (leading, trailing, or between words).
- A backup of your data or a duplicate column if you are using the destructive Find and Replace method.
Step-by-Step
Method 1: Using Find and Replace (Best for Permanent Removal)
Use this method when you want to completely eliminate all spaces in a range of cells, turning "New York City" into "NewYorkCity". Note that labels may differ slightly by version or region, but the core shortcuts remain the same.
- Select the cells, columns, or rows containing the text you want to modify. If you select the entire sheet, be careful not to remove spaces in areas where they are needed.
- Open the Find and Replace dialog box by pressing Ctrl + H on your keyboard (or Cmd + Shift + H on Mac). Alternatively, go to the Home tab, click Find & Select in the Editing group, and choose Replace.
- In the Find what field, press the spacebar once. It will look empty, but the cursor will move one position to the right.
- Leave the Replace with field completely empty. Do not enter a space or any other character here.
- Click Replace All. Excel will notify you of how many replacements were made.
- Click OK and close the dialog box.
Method 2: Using the SUBSTITUTE Function (Best for Dynamic Data)
If you have a list that changes frequently, a formula is better because it updates automatically when the source text changes. The SUBSTITUTE function replaces specific text with other text.
- Click on an empty cell next to the data you want to clean (e.g., if your text is in cell A2, click cell B2).
- Type the following formula:
=SUBSTITUTE(A2, " ", ""). - Breakdown of the formula: A2 is the cell containing the text; " " (a space inside quotes) tells Excel what to look for; "" (no space inside quotes) tells Excel to replace it with nothing.
- Press Enter. The result will appear in cell B2 with all spaces removed.
- To apply this to the rest of your list, hover your mouse over the bottom-right corner of cell B2 until a small black cross (the fill handle) appears. Click and drag the handle down to the end of your data range.
- (Optional) If you want to replace the original data with these results, copy the formula cells, right-click the original cells, and select Paste Values (the icon with "123"). This removes the formula and keeps only the cleaned text.
Method 3: Using the TRIM Function (Best for Cleaning Extra Spaces)
Sometimes you don't want to remove all spaces, but rather the "invisible" errors—like double spaces between words or trailing spaces at the end of a sentence. The TRIM function is designed specifically for this.
- Select an empty cell next to your data.
- Type the formula:
=TRIM(A2). - Press Enter. The TRIM function removes all leading and trailing spaces and reduces multiple spaces between words to a single space.
- Drag the fill handle down to apply the formula to the rest of your column.
- As with the SUBSTITUTE method, use Paste Values if you need to overwrite the original messy data with the cleaned version.
Common Mistakes
- Over-selecting Data: Using "Replace All" on the entire worksheet instead of a specific column. This can accidentally break formulas or remove spaces from headers and other critical labels.
- Confusing TRIM with SUBSTITUTE: A common error is using TRIM when the goal is to remove every space. TRIM leaves one space between words; only SUBSTITUTE can remove all of them.
- Forgetting to Paste Values: When using formulas, users often delete the original column before converting the formula results to values. This results in a
#REF!error because the formula no longer has a source cell to reference. - Adding a Space in the "Replace With" Box: In the Find and Replace tool, if you accidentally hit the spacebar in the "Replace with" field, you are simply replacing a space with another space, and nothing will change.
Tips
- Use a Helper Column: Always perform your cleaning in a new column first. Once you verify the results are correct, you can delete the original column. This prevents permanent data loss if you make a mistake.
- Combine TRIM and SUBSTITUTE: If your data is extremely messy (containing non-breaking spaces from the web), you can nest functions:
=SUBSTITUTE(TRIM(A2), " ", ""). - Keyboard Shortcuts: To speed up the process, use Ctrl + Shift + Down Arrow to select large blocks of data quickly before launching the Find and Replace tool.
- Check for Non-Breaking Spaces: If Find and Replace doesn't work, your data might contain "non-breaking spaces" (often found in data copied from websites). These are different from standard spaces. You can remove these using the formula
=SUBSTITUTE(A2, CHAR(160), "").
Troubleshooting
If you followed the steps but the spaces are still there, try these solutions in order:
- Check for Hidden Characters: If the Find and Replace tool says "0 replacements made" but you clearly see spaces, you likely have non-breaking spaces (Unicode character 160). Use the
=SUBSTITUTE(A2, CHAR(160), "")formula mentioned in the Tips section. - Verify Cell Formatting: Ensure the cells are formatted as "General" or "Text". If a cell is formatted as a specific custom number format, it might be adding visual padding that looks like a space but isn't actually a character in the cell.
- Refresh the Sheet: If you are using a formula and the result isn't updating, check if your Calculation Options are set to "Manual". Go to the Formulas tab > Calculation Options and select Automatic.
- Restart Excel: In rare cases, the Find and Replace tool can glitch if the workbook is extremely large or corrupted. Save your work, close the application, and reopen the file.
Frequently Asked Questions
Can I remove spaces using a Macro or VBA?
Yes, for very large datasets across multiple sheets, you can write a VBA script using the .Replace method. This is only recommended for advanced users who need to automate the process across hundreds of files.
Does the TRIM function remove spaces inside the word?
No. TRIM only removes spaces at the very beginning and very end of the text, and it turns double or triple spaces between words into a single space. To remove all internal spaces, use SUBSTITUTE.
Will removing spaces affect my formulas?
If you use Find and Replace on a cell that contains a formula, you risk breaking the formula syntax. Always select only the data cells, or use the SUBSTITUTE function in a separate column to avoid altering the logic of your calculations.
How do I remove only the first space in a cell?
The SUBSTITUTE function allows you to specify which instance of the text to replace. Use =SUBSTITUTE(A2, " ", "", 1). The "1" at the end tells Excel to only replace the first space it encounters.
Is there a way to remove spaces in bulk across multiple workbooks?
Excel does not have a built-in "cross-workbook" find and replace. You must open each workbook individually or use a Power Query merge to clean the data from multiple sources simultaneously.