TRIM Not Working in Excel? Remove Non-Breaking Spaces (CHAR 160)

TRIM leaves spaces behind? Find out exactly which character it is with one formula, then remove non-breaking spaces (CHAR 160), line breaks, tabs and zero-width characters in Excel or Google Sheets.

On this page

Tested in: Live formula checks in Microsoft Excel 16.114.4 for Mac (English UI; system region zh-Hans_US), November 8, 2026; Google Sheets (spreadsheet locale zh_CN), November 9, 2026. Results and platform differences are noted below; this is not a certification of every menu workflow.

Which versions this applies to

  • Excel for Microsoft 365, 2024, 2021, 2019, 2016 (Windows, Mac, web): TRIM, SUBSTITUTE, CLEAN, UNICHAR and UNICODE work in all of them. The one-cell “X-ray” formula in Step 1 needs TEXTJOIN and SEQUENCE (Excel 365/2021+). An alternative for older versions is included.
  • Google Sheets: Same problem, same functions. Google’s own TRIM page says non-breaking spaces are not trimmed. Sheets-specific options are below.

Why TRIM ignores some spaces

Microsoft’s data-cleaning guide is specific: TRIM removes the 7-bit ASCII space (value 32), CLEAN removes nonprinting characters 0–31, and for higher characters, including 160, you’re expected to use SUBSTITUTE to replace them with something TRIM and CLEAN understand. So TRIM isn’t broken. It’s doing exactly its job, and the character in your cell isn’t the one it handles.

A non-breaking space looks identical to a normal space on screen. Web pages use it ( ) to keep words together, so it comes along whenever you copy from a browser, a PDF or an HTML email.

Step 1: Find out which character it is

Don’t guess. List the code of every character in the cell. In Excel 365, Excel 2021 or Google Sheets:

=TEXTJOIN(",",TRUE,UNICODE(MID(A2,SEQUENCE(LEN(A2)),1)))

For a cell containing SKU-101 followed by a non-breaking space, this returns:

83,75,85,45,49,48,49,160

The last code, 160, is the problem. In Google Sheets, ARRAYFORMULA is required for this X-ray pattern: =ARRAYFORMULA(TEXTJOIN(",",TRUE,UNICODE(MID(A2,SEQUENCE(LEN(A2)),1)))). In the live check, the unwrapped version returned only 32; the wrapped version returned 32,65,160,32.

Excel 2019 and earlier: put the numbers 1, 2, 3 … across B1:T1 and this in B2, then fill right:

=IFERROR(UNICODE(MID($A2,B$1,1)),"")

What the codes mean

CodeCharacterTypical sourceRemoved by TRIM?Removed by CLEAN?
32Normal spaceTyping✅❌
160Non-breaking spaceWeb pages, PDFs, HTML email, some ERP exports❌❌
8239Narrow no-break spaceNumber formatting in some locales (e.g. “1 234”)❌❌
8201 / 8199Thin space / figure spaceTypeset documents❌❌
12288Full-width (ideographic) spaceChinese/Japanese/Korean input❌❌
9TabText files, copied tables❌✅
10 / 13Line feed / carriage returnAlt+Enter, multi-line exports❌✅
8203Zero-width spaceWeb pages, chat apps❌❌
65279Zero-width no-break space (BOM)Start of some UTF-8 files❌❌

The TRIM and CLEAN columns follow Microsoft’s documentation (TRIM handles 32, CLEAN handles 0–31). The 8239/12288/8203 rows were also checked in LibreOffice: TRIM left them all in place.

Step 2: Remove non-breaking spaces (the usual fix)

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

Replace 160 with a space, not with nothing. Between two words, a non-breaking space is a real separator. Delete it and “New York” becomes “NewYork”. TRIM then removes any leftovers at the ends and collapses doubles.

CHAR(160) or UNICHAR(160)? On Excel for Windows both work. But CHAR depends on the platform’s character set: Microsoft’s CODE documentation says Mac uses the Macintosh character set. In our LibreOffice check, SUBSTITUTE(A2,CHAR(160),"") did not remove the non-breaking space, while UNICHAR(160) did. UNICHAR is the safe choice when a file is shared across platforms.

Make it permanent: put the formula in a helper column, fill it down, copy, then Paste Special > Values over the original column and delete the helper. Until you do this, lookups and pivot tables still read the original, dirty column.

Step 3: Remove common invisible spaces in one formula

When the X-ray shows a mix of characters, nest the replacements. Spaces become normal spaces, line breaks and tabs become spaces, and zero-width characters are deleted:

=TRIM(CLEAN(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A2,UNICHAR(160)," "),UNICHAR(8239)," "),UNICHAR(8201)," "),UNICHAR(12288)," "),CHAR(10)," "),CHAR(9)," "),UNICHAR(8203),""),UNICHAR(65279),"")))

In LibreOffice, a test string containing a leading non-breaking space, a narrow no-break space, a thin space, an ideographic space, a zero-width space and a line break came out as clean single-spaced text.

Why replace line breaks before CLEAN? CLEAN deletes codes 0–31, so Line1 + line feed + Line2 becomes Line1Line2. Replacing CHAR(10) with a space first keeps the words apart.

In Excel 365 you can make this easier to maintain with LET. The list of codes sits in one place:

=LET(t,A2,
 step1,SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(t,UNICHAR(160)," "),UNICHAR(8239)," "),UNICHAR(8201)," "),UNICHAR(12288)," "),CHAR(10)," "),CHAR(9)," "),
 step2,SUBSTITUTE(SUBSTITUTE(step1,UNICHAR(8203),""),UNICHAR(65279),""),
 TRIM(CLEAN(step2)))

Step 4: TRIM “worked” but the problem is still there

If the X-ray shows only normal characters and things still don’t match, the problem isn’t spaces:

The formula result is text, and you need a number

=TRIM(" 123 ") returns the text “123”. In LibreOffice, ISTEXT(TRIM(A2)) returned TRUE for a padded number. SUM ignores it and lookups against real numbers fail. Convert while cleaning:

=--TRIM(SUBSTITUTE(A2,UNICHAR(160),""))

Here 160 is replaced with nothing, because a space inside a number (“1 234”) would stop the conversion. More methods: convert numbers stored as text.

You cleaned a copy, not the original

Your TRIM column is clean, but XLOOKUP, COUNTIF or the pivot table still point at the original column. Either repoint them or paste the clean values over the original (Step 2).

Calculation is set to Manual

If a new TRIM formula shows the old value until you press F9, check Formulas > Calculation Options and set it to Automatic.

The difference is case, or a look-alike character

A Latin “A” and a Cyrillic U+0410 look the same but have different codes. The X-ray formula shows that too: compare the codes of the two cells side by side.

For the full list of reasons a lookup fails on “identical” values, see XLOOKUP returns #N/A even though the value exists.

Fix it without formulas: Find and Replace

  1. Click a dirty cell, select the invisible character at the end in the formula bar, and copy it (Ctrl+C).
  2. Select the column and press Ctrl+H.
  3. Paste the character into Find what, type a single space (or nothing, for numbers) in Replace with, then click Replace All.

Many guides suggest typing Alt+0160 on the numeric keypad in the Find box instead. Copying the real character works on every keyboard and on Mac.

Google Sheets: what’s different

  • TRIM: Google’s documentation states it directly: “Whitespace or non-breaking space will not be trimmed.” The same Step 2 formula works, and in Sheets CHAR(160) is also safe, because Google’s CHAR uses the Unicode table.
  • Data > Data cleanup > Trim whitespace: handy, but Google’s help page notes that it doesn’t trim non-breaking spaces either.
  • REGEXREPLACE can handle several characters at once:
=TRIM(REGEXREPLACE(REGEXREPLACE(A2,"[\x{00A0}\x{2009}\x{202F}\x{3000}\t\n\r]"," "),"[\x{200B}\x{FEFF}]",""))

Google Sheets uses RE2 syntax, where \x{00A0} means code 160 (hex A0).

  • Find and replace (Ctrl+H) with Search using regular expressions ticked accepts the same pattern, for example \x{00A0}.

Diagnostic checklist

What you seeTestFix
LEN(A2) > visible characters, TRIM changes nothingX-ray formula shows 160TRIM(SUBSTITUTE(A2,UNICHAR(160)," "))
Words run together after CLEANCodes 10/13 between wordsReplace CHAR(10) with ” ” before CLEAN
Still too long after SUBSTITUTE 160Codes 8239, 8201, 12288Add a SUBSTITUTE for each (Step 3)
Length is 1 more than expected, nothing visible8203 or 65279SUBSTITUTE with ""
Clean text, but SUM ignores it=ISTEXT(B2) is TRUE--TRIM(…) or VALUE
Clean column, lookups still failFormula referencesPaste values over the original

Common mistakes

  1. Replacing CHAR(160) with "" in text. It deletes word separators. Use ” ” for text and "" for numbers.
  2. Running CLEAN on multi-line text without replacing line breaks first. It glues the lines together.
  3. Relying on CHAR(160) in files opened on a Mac. Use UNICHAR(160).
  4. Trimming a helper column and forgetting to paste values back. Your reports still read the dirty data.
  5. Assuming Data cleanup > Trim whitespace in Google Sheets handles everything. Google says it skips non-breaking spaces.

FAQ

Why is TRIM not removing spaces in Excel?

The spaces are probably non-breaking spaces (code 160), which TRIM doesn’t touch. Check with =UNICODE(RIGHT(A2)) and fix with =TRIM(SUBSTITUTE(A2,UNICHAR(160),” ”)).

How do I remove CHAR(160) in Excel?

Use SUBSTITUTE to replace it with a normal space, then TRIM: =TRIM(SUBSTITUTE(A2,UNICHAR(160),” ”)). For numbers, replace it with nothing and convert: =—SUBSTITUTE(A2,UNICHAR(160),"").

Does TRIM remove line breaks?

No. TRIM only removes normal spaces. CLEAN removes line breaks, but replace them with a space first so words don’t merge: =TRIM(CLEAN(SUBSTITUTE(A2,CHAR(10),” ”))).

Does TRIM remove non-breaking spaces in Google Sheets?

No. Google’s documentation says non-breaking spaces are not trimmed by the TRIM function or by Data cleanup > Trim whitespace. Use SUBSTITUTE or REGEXREPLACE first.

How can I see hidden characters in a cell?

List each character’s code with =TEXTJOIN(”,“,TRUE,UNICODE(MID(A2,SEQUENCE(LEN(A2)),1))). A normal space is 32, and anything like 160, 8203 or 10 is a hidden character.

Live-test findings

Step 3 and LET now both replace thin spaces (U+2009) and tabs, and remove BOM (U+FEFF) as well as U+200B. LET uses step1/step2: t1/t2 are cell addresses and are invalid names in Excel. These are targeted replacements, not a guarantee for every Unicode separator.

On the tested Mac, UNICODE(CHAR(160)) was 8224 (a dagger), not 160. Use UNICHAR(160) for cross-platform files. In Sheets, both CHAR(160) and UNICHAR(160) produced 160, but TRIM left the non-breaking space intact. The Sheets REGEXREPLACE version also passed.

Sources

Oscar

Spreadsheet formulas and troubleshooting. See each article for its actual verification environment and pending author checks.

Tested in Microsoft Excel 16.114.4 for Mac (English UI; system region zh-Hans_US), November 8, 2026; Google Sheets (spreadsheet locale zh_CN), November 9, 2026.

Next in Data Cleaning & Entry Convert Numbers Stored as Text in Excel and Google Sheets (5 Methods)