Function · Text
Excel TRIM function
The Excel TRIM function removes extra spaces from text. It does not remove the non-breaking space you get from a web page.
Syntax =TRIM(text)
=TRIM(" Maria Lopez ")Arguments
| Name | Required | What to pass |
|---|---|---|
| text | Required | The text to clean. Leading and trailing spaces go away. Repeated spaces between words become one space. |
Examples
A name pasted with extra spaces
=TRIM(B1)Result Maria Lopez
| A | B | |
|---|---|---|
| 1 | Raw | Maria Lopez |
| 2 | Clean | Maria Lopez |
TRIM deletes spaces at both ends and collapses runs of spaces between words to a single space. Maria Lopez becomes Maria Lopez. The spaces it understands are ordinary spaces, character 32.
A name copied from a web page often has a non-breaking space, character 160, where you see a gap. TRIM leaves that character in place, so the cell still fails an exact match against Maria Lopez. SUBSTITUTE the non-breaking space with a normal space first. The LAMBDA how-to wraps that pair of steps in one name, because the two-function version is easy to forget.