Function Problems

How to Fix Excel TRIM Not Removing Non-Breaking Spaces

Adam DavisAdam Davis Oct 28, 2026 872 views

Question details

The user needs to remove trailing spaces from their data, but the standard TRIM function is leaving non-breaking spaces behind.

How to Fix Excel TRIM Not Removing Non-Breaking Spaces
Product
Spreadsheet
Device & OS
not provided
Scenario
Cleaning text data in a spreadsheet after importing or pasting it from an external source.
Observed behavior
The TRIM function successfully removes regular spaces but ignores non-breaking spaces (character code 160), leaving the data improperly formatted.
Before you start

Identify the cell containing the text you want to clean, and ensure you have an empty adjacent column to input the cleaning formula before replacing the original data.

Solution 1Recommended

Use a Combined Formula to Remove All Extra Spaces

This is the most robust method to remove regular spaces, non-printable characters, and non-breaking spaces all at once.

Because the TRIM function only recognizes standard spaces (character code 32), it fails on non-breaking spaces (character code 160) often found in web-copied data. By nesting SUBSTITUTE, CLEAN, and TRIM, you can handle all unwanted spacing in a single step.

1
Select a blank cell

Click on an empty cell next to your data (for example, B2 if your messy data is in A2).

2
Enter the nested formula

Type the formula =SUBSTITUTE(CLEAN(TRIM(A2)),CHAR(160),"") and press Enter.

3
Apply to the entire column

Click the bottom-right corner of the cell containing the formula and drag the fill handle down to apply it to the rest of your dataset.

4
Replace original data

Copy the newly cleaned values, right-click the first cell of your original column, and select 'Paste as Values' to permanently replace the old data.

Use a Combined Formula to Remove All Extra Spaces
Formula Breakdown: TRIM removes regular extra spaces, CLEAN removes non-printable characters, and SUBSTITUTE specifically targets the non-breaking space (CHAR 160) and replaces it with nothing.
Clean Data Easily in WPS Spreadsheet

Use WPS Spreadsheet to Clean Text Data

WPS Spreadsheet fully supports advanced text functions like SUBSTITUTE, CLEAN, and TRIM, allowing you to clean up messy data imported from the web or other software effortlessly.

  1. 1. Open WPS Spreadsheet: Launch WPS Office and open your workbook in WPS Spreadsheet.
  2. 2. Input the formula: Select a blank cell next to your data and type =SUBSTITUTE(CLEAN(TRIM(A2)),CHAR(160),"").
  3. 3. Apply to data: Press Enter and drag the fill handle to apply the formula to the rest of your dataset.
  4. 4. Paste as values: Copy the cleaned data, right-click the original cells, and choose 'Paste Special' > 'Values'.
Fully compatible with Microsoft Excel formulas and functions, including SUBSTITUTE and TRIM.Seamlessly handles text cleaning and data formatting for large datasets.Free, lightweight, and fast to load.Familiar user interface with no learning curve.
microsoft office alternative - wps office

Frequently Asked Questions

Why does the TRIM function ignore some spaces?

The TRIM function is strictly designed to remove the standard space character (ASCII value 32). It does not recognize or remove non-breaking spaces (ASCII value 160), which are commonly generated in HTML web pages or imported data.

How do I know if my text contains non-breaking spaces?

If you use the TRIM function and still see trailing or leading spaces, or if testing the space with the formula =CODE(RIGHT(A2, 1)) returns 160, your text contains non-breaking spaces.

Can I use Find and Replace to remove non-breaking spaces?

Yes. You can open the Find and Replace dialog (Ctrl+H), click inside the 'Find what' field, hold the Alt key, and type 0160 on your numeric keypad. Leave the 'Replace with' field blank and click 'Replace All'.

What does the CLEAN function do in this formula?

The CLEAN function removes the first 32 non-printing characters in the 7-bit ASCII code (values 0 through 31) from text. It is often paired with TRIM to ensure imported data is completely free of hidden formatting characters before processing.