Remove extra spaces and hidden characters
Clean up text pasted from websites or other systems so lookups and comparisons work.
The formula
Excel and Google Sheets
=TRIM(CLEAN(SUBSTITUTE(A2, CHAR(160), " ")))How it works
SUBSTITUTE(A2, CHAR(160), " ")Turns non-breaking spaces (common in web copy) into normal spaces.
CLEAN(…)Removes line breaks and other non-printing characters.
TRIM(…)Removes leading and trailing spaces and squeezes repeated spaces to one.
Example
| A: Raw | B: Result |
|---|---|
| " Acme Ltd " | Acme Ltd |
| "North⏎East" | NorthEast |
Tips
- Paste the results back as values (Ctrl+Shift+V in Sheets, Paste Special > Values in Excel) to replace the originals.