# How to remove extra spaces from text in Excel

Use =TRIM(A2). It removes spaces at the start and end and turns runs of spaces between words into one.

**Excel:** `=TRIM(A2)` (Every current version)

**Google Sheets:** the same formula works.

## Example

Sample data (row 1 is the header):

| A | B |
| --- | --- |
| Imported name | Clean |
|   Maria Lopez |  |
| James   O'Neil   |  |
| Aiko Tanaka |  |
|  Lars  Eriksen  |  |
| Chidi Okafor    |  |

Formula in B2, filled to B6: `=TRIM(A2)`

Result: Maria Lopez; James O'Neil; Aiko Tanaka; Lars Eriksen; Chidi Okafor

## How it works

TRIM strips leading and trailing spaces and collapses repeated spaces inside the text to a single space. Extra spaces are the most common reason a lookup returns #N/A for a value you can see.

## Other ways

- `=TRIM(CLEAN(A2))`: CLEAN also removes line breaks and other non-printing characters from pasted data.

## Common mistakes

- TRIM doesn't remove non-breaking spaces (character 160) from web pages. Use `=TRIM(SUBSTITUTE(A2,CHAR(160)," "))`.
- The cleaned text is in a new column. To replace the original, copy the results and Paste Values over it.

## Questions

**How do I remove all spaces, not just extra ones?**

Use SUBSTITUTE: `=SUBSTITUTE(A2," ","")`.

**Why does my lookup still fail after TRIM?**

Check for non-breaking spaces or for a number stored as text in one of the two lists.

Every formula and result on this page was checked by running it in the Spreadsheet Practice formula engine on 2026-10-29.

Source: https://spreadsheetpractice.com/formulas/remove-extra-spaces
