Data typed by people is messy. Some names are in CAPITALS, some in lowercase, some have spaces before or after, some have two spaces in the middle. It looks like a cosmetic problem, but it breaks real work: "Lagos " with a trailing space is not equal to "Lagos", so SUMIFS skips it and XLOOKUP can't find it. Cleaning text is the first job with any list someone else typed.
Open m5-text-dates-practice.xlsx, sheet Customers. Column A is a mess.
The cleaning functions
| Function | What it does | " tunde BELLO " becomes |
|---|---|---|
TRIM | removes spaces at both ends; reduces inner double spaces to one | "tunde BELLO" |
PROPER | Capital First Letter Of Each Word | " Tunde Bello " |
UPPER | ALL CAPITALS | " TUNDE BELLO " |
LOWER | all small letters | " tunde bello " |
CLEAN | removes invisible “non-printing” characters (from copied web pages or systems) | — |
They're most useful together. In E2:
=PROPER(TRIM(A2))
The inner function runs first (TRIM removes the spaces), then PROPER fixes the capitals.

Replace the messy column with the clean one
A cleaning formula lives in a helper column. When you're happy with it:
- Select the clean column (E2:E31) → Copy (Ctrl+C).
- Right-click the original column's first cell → Paste Special → Values (the clipboard icon with 123).
- Delete the helper column.
Paste Values pastes the results, not the formulas, so deleting the helper column doesn't break anything.
Flash Fill: cleaning by example
For many patterns you don't need a formula at all.

Type what you want for the first row, start the second, and Excel spots the pattern. Flash Fill can:
- pull out first names or surnames,
- reformat phone numbers (
0803-456-7812→08034567812), - join columns (Okafor, Adaeze),
- extract codes from the middle of text.
Find and Replace
Ctrl+H opens Find and Replace — the quickest cleaner of all:
- Replace
"Abj"with"Abuja"in the whole sheet. - Replace two spaces with one (click Replace All a few times).
- Replace
"₦"with nothing to turn text prices back into numbers.
Click Options to limit it to the selection, match case, or match the entire cell only.
Check yourself
Answer in your head first, then open each question to see the answer and why.
Why can "Lagos " (with a space at the end) cause wrong totals?
- A Excel adds the space as a number
- B It doesn't equal "Lagos", so SUMIFS and lookups skip it
- C It changes the font
- D It hides the row
Show the answer
B) It doesn't equal "Lagos", so SUMIFS and lookups skip it — To Excel, text with an extra space is different text. TRIM fixes it.
What does =PROPER(TRIM(" ngozi EZE ")) return?
- A "Ngozi Eze"
- B "NGOZI EZE"
- C " Ngozi Eze "
- D "ngozi eze"
Show the answer
A) "Ngozi Eze" — TRIM removes outer spaces and extra inner spaces; PROPER capitalises each word.
After cleaning names with a formula in a helper column, how do you keep just the results?
- A Copy, then Paste Special → Values
- B Delete the original column first
- C Press Ctrl+`
- D Use Format Painter
Show the answer
A) Copy, then Paste Special → Values — Paste Values pastes the results without formulas, so the helper column can be removed.
What is the shortcut for Flash Fill?
- A Ctrl+F
- B Ctrl+E
- C Ctrl+H
- D Ctrl+L
Show the answer
B) Ctrl+E — Ctrl+E runs Flash Fill (Data → Flash Fill).
More free lessons: Why Excel, and how this course works · A tour of the Excel window · Number formats: naira, percentages, dates and phone numbers · Your first formulas: + − × ÷ and the order Excel follows · IF: make Excel decide · Excel Tables: the habit that saves hours · Choosing the right chart · Your first PivotTable · Printing that looks right the first time · Revision guide and how the final exam works