How to Remove Extra Spaces Between Words in Excel Using TRIM

📅 Jan 12, 2026 📝 Sarah Miller

Clean data is vital, yet inconsistent spacing in imported Excel datasets often disrupts lookups, causing frustrating calculation errors. When consolidating financial records from standard funding sources like public grants or internal capital, misaligned text can completely stall your reporting. Fortunately, mastering a simple formula grants immediate data integrity and automates your cleanup process.

Stipulation: Note that standard trimming handles regular spaces, but non-breaking spaces from web exports require a nested substitute function.

Utilizing the TRIM function to purge redundant spaces ensures flawless analysis. Below, we outline the exact formulas and steps to sanitize your workbook.

How to Remove Extra Spaces Between Words in Excel Using TRIM

Data imported into Excel from external databases, web pages, or PDF reports is rarely pristine. One of the most common issues data analysts face is irregular spacing. Extra spaces can sneak in at the beginning of a text string (leading spaces), at the very end (trailing spaces), or as multiple consecutive spaces between words.

These redundant spaces are more than just an aesthetic eyesore; they can completely break your spreadsheet's functionality. Because Excel treats "Apple" and "Apple " (with a trailing space) as two entirely different values, extra spaces will cause lookup formulas like VLOOKUP, XLOOKUP, or MATCH to return frustrating #N/A errors.

Fortunately, Excel provides a suite of powerful functions to tackle this issue. In this comprehensive guide, we will explore how to trim excess spaces between words in a cell, starting with the basic TRIM function and moving to advanced, fail-safe nested formulas designed to handle stubborn, non-printing web characters.

The Standard Solution: The TRIM Function

For most everyday data-cleaning tasks, Excel's built-in TRIM function is your best friend. It is specifically programmed to handle the standard space character (ASCII value 32).

How TRIM Works

The TRIM function works by executing three rules on any text string it processes:

  • It removes all leading spaces (spaces before the first word).
  • It removes all trailing spaces (spaces after the last word).
  • It compresses any multiple consecutive spaces between words down to a single space.

Syntax

=TRIM(text)

Where text is either a hardcoded string in quotation marks or, more commonly, a reference to a cell containing the text you want to clean (e.g., A2).

Example Walkthrough

Imagine you have the following messy text in cell A2:

"   Financial    Report   2024  "

To clean this text, you would write the following formula in cell B2:

=TRIM(A2)

The result returned in cell B2 will be:

"Financial Report 2024"

Notice how all leading and trailing spaces have vanished, and the gaps between "Financial", "Report", and "2024" have been normalized to exactly one space.

When TRIM Fails: The Non-Breaking Space Issue

Sometimes, you will apply the TRIM formula to a column of messy data, and absolutely nothing will change. The extra spaces remain stubbornly in place. When this happens, it is usually because you are dealing with non-breaking spaces.

Non-breaking spaces (often written as   in HTML) are commonly used on websites to prevent browsers from automatically wrapping text to a new line. When you copy-paste data from a web page into Excel, these characters are imported along with the text.

To Excel, a standard space is character 32 in the ASCII set, while a non-breaking space is character 160. Because the standard TRIM function only looks for and removes character 32, it completely ignores character 160.

The Solution: Combining TRIM and SUBSTITUTE

To remove these stubborn non-breaking spaces, you must first convert them into standard spaces, and then apply the TRIM function. We can achieve this by nesting the SUBSTITUTE and CHAR functions inside TRIM.

The Formula

=TRIM(SUBSTITUTE(A2, CHAR(160), " "))

How this Formula Works Step-by-Step:

  1. CHAR(160): This tells Excel to identify the non-breaking space character.
  2. SUBSTITUTE(A2, CHAR(160), " "): This looks at cell A2, finds every instance of a non-breaking space (character 160), and replaces ("substitutes") it with a standard space (" ", which is character 32).
  3. TRIM(...): Once all non-breaking spaces have been converted to standard spaces, the outer TRIM function can easily strip away the leading, trailing, and excessive middle spaces.

Taking It a Step Further: Removing Non-Printable Characters

In addition to standard and non-breaking spaces, imported data sometimes contains non-printable control characters, such as line breaks (character 10 and 13) or tab characters. These characters can cause strange formatting issues and disrupt formulas.

To clean up these elements alongside extra spaces, we can incorporate Excel's CLEAN function into our formula array.

The "Ultimate" Data Cleaning Formula

If you want a bulletproof formula that removes all leading/trailing spaces, normalizes internal spaces, converts non-breaking web spaces, and strips out non-printable characters, use this nesting order:

=TRIM(CLEAN(SUBSTITUTE(A2, CHAR(160), " ")))

This formula processes the text in cell A2 from the inside out:

  • First, it swaps out non-breaking web spaces for standard spaces.
  • Second, it passes the text to CLEAN, which strips out any hidden control characters or line breaks.
  • Finally, it passes the clean string to TRIM, which removes all remaining redundant standard spaces.

Quick Reference: Space Cleaning Formulas

Here is a quick-glance table to help you choose the right formula for your specific scenario:

Scenario Formula Primary Use Case
Standard Cleanup =TRIM(A2) Removes normal leading/trailing and excess internal spaces (ASCII 32).
Web-Imported Data =TRIM(SUBSTITUTE(A2, CHAR(160), " ")) Converts non-breaking spaces (ASCII 160) to standard spaces, then trims them.
Complete Data Scrubbing =TRIM(CLEAN(SUBSTITUTE(A2, CHAR(160), " "))) Removes non-breaking spaces, strips non-printable control characters, and trims standard spaces.
Remove ALL Spaces =SUBSTITUTE(A2, " ", "") Removes every single space in the cell (useful for cleaning up phone numbers or IDs).

How to Replace the Original Messy Data with Cleaned Text

Because formulas are dynamic, you cannot simply delete your original column of messy text after applying your TRIM formula; doing so would result in a column full of #REF! errors. To finalize your work, you must convert your formulas into static values.

Follow these quick steps to lock in your clean data:

  1. Select the range of cells containing your cleaning formula (e.g., column B).
  2. Press Ctrl + C on your keyboard to copy the cells.
  3. Right-click on the original messy data column (e.g., column A) or your new column.
  4. Under Paste Options, click the Values icon (which looks like a clipboard with the numbers "123"). Alternatively, press Ctrl + Alt + V to open the Paste Special dialog, select Values, and click OK.
  5. You can now safely delete the helper column containing the active formulas.

Conclusion

Irregular spacing is one of the most common clean-up tasks you will encounter in Microsoft Excel. By understanding how the TRIM function works-and how to pair it with SUBSTITUTE and CLEAN to neutralize web-based non-breaking spaces-you can handle even the most stubborn text formatting issues with ease. Bookmark these formulas to save yourself hours of manual editing on your next data import!

Disclaimer:
The documents and templates provided on this page are for informational and illustrative purposes only. They do not constitute professional, legal, or financial advice, and should not be relied upon as such. Because individual circumstances and regulatory requirements vary, these materials may not be suitable for your specific needs. We recommend consulting with a qualified professional before adapting or using any of these examples for official or commercial purposes.