Clean extra spaces
| A | |
|---|---|
| 1 | Name |
| 2 | John Smith |
Formula: C1: =TRIM(A2)
Result: John Smith
Leading and trailing spaces are removed and the three inner spaces become one.
Removes extra spaces.
TRIM(text)Example: =TRIM(A2)
Available in: All versions
TRIM removes leading and trailing spaces from text and reduces any run of spaces inside to a single space: =TRIM(text). It is the first step in cleaning imported data before lookups or counts.
| A | |
|---|---|
| 1 | Name |
| 2 | John Smith |
Formula: C1: =TRIM(A2)
Result: John Smith
Leading and trailing spaces are removed and the three inner spaces become one.
| A | |
|---|---|
| 1 | Name |
| 2 | John Smith |
Formula: C1: =LEN(TRIM(A2))
Result: 10
The raw text has 16 characters; the cleaned text has 10.
| A | B | C | |
|---|---|---|---|
| 1 | Name | Staff | |
| 2 | Ben | Ana | |
| 3 | Ben | ||
| 4 | Cara |
Formula: E1: =MATCH(TRIM(A2),C2:C4,0)
Result: 2
Without TRIM, " Ben " would not match "Ben" and MATCH would return #N/A.
A tiny spreadsheet with example data. Edit the formula or any number and see the result.
Formula in D2: =TRIM(A4)
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Text | Other | Result | |
| 2 | Alice Johnson | alice johnson | extra spaces | |
| 3 | [email protected] | [email protected] | ||
| 4 | extra spaces | |||
| 5 | SKU-2026-0415 | |||
| 6 | iced coffee, tea, sugar | |||
| 7 | Order 417 shipped |
Enter — commit · F2 — edit · F4 — $ in a reference · Ctrl+C/Ctrl+V — copy and paste · Ctrl+Z — undo
Esc or F6 — leave the sheet for the «Check» button · Shift+Tab in the first cell — back to the page