A name with a trailing space looks identical to the same name without one, but to Excel they are different values, so a lookup fails and a filter splits one person into two. TRIM removes leading and trailing spaces, and pasting the result as values makes the fix permanent.
Prerequisites
- Excel
- The CSV opened in Excel
- A copy of the source file, so the original stays untouched.
Steps
- Add a helper column beside the name column with the formula =TRIM(A2), adjusted to the name column.
- Copy the helper column down, then check that the trimmed names look right.
- Copy the helper column and use Paste Special, Values, over the original name column.
- Delete the helper column, then test a lookup or filter on a name that failed before.
- Save the file as .xlsx so the cleaned values are kept.
Worked example: Fictional volunteer names after trimming
The practice table below is a fictional five-volunteer list after trimming. The count column is 1 per volunteer, and the total is the number of volunteers. The table below is fictional practice material, with fictional values. It is the expected result, worked out by hand, not a run of any tool.
| Name | Count |
|---|---|
| Amara Okafor | 1 |
| Ben Whitfield | 1 |
| Clara Jensen | 1 |
| Dev Patel | 1 |
| Elena Rossi | 1 |
| Total | 5 |
Expected result. Five names trimmed, each counted once, and a lookup on any name now finds its row.
Limits
- TRIM removes only standard spaces, so a non-breaking space from a web export needs CLEAN or Find and Replace as well.
- TRIM also reduces multiple spaces between words to one, which is usually wanted but should be checked on names with double surnames.
