
Before turning a table into a pivot table or chart, the most time-consuming job is data cleaning. Files from outside often contain extra spaces, repeated rows, numbers stored as text and dates in mixed formats. In this guide we make messy data ready for analysis in 12 steps.
0. Back up first and work on a copy
Cleaning makes changes that are hard to undo. Keep the raw data on a separate sheet as it is and clean a copy. Turning the data into a table with Ctrl + T makes the work easier (see our Excel tables guide).
1. Clean extra spaces
Invisible leading/trailing spaces break matching (VLOOKUP can't find).
=TRIM(A2)TRIM removes leading and trailing spaces and reduces extra spaces between words to one. For non-printable characters such as line breaks use =CLEAN(A2). For the non-breaking space (from the web) add =SUBSTITUTE(A2,CHAR(160)," ").
2. Remove duplicate records
With Data > Remove Duplicates choose which columns define a duplicate. Before deleting, flag duplicates with conditional formatting and review them (see our remove duplicates guide).
3. Fix numbers stored as text
A green triangle in the top-left of the cell, or left-aligned content, suggests the number may be text.
- Select the cell and use warning icon > Convert to Number.
- Or type 1 in an empty cell and copy it, select the range and Paste Special > Multiply.
- With a formula:
=VALUE(A2).
If the decimal separator differs (point/comma), first fix it with SUBSTITUTE.
4. Standardise dates
Dates arriving in different formats can remain text. First check the cell format; if needed use Data > Text to Columns > Date. With a formula: =DATEVALUE(A2). Splitting year-month-day parts and rebuilding with =DATE(year,month,day) is also safe (see our date functions guide).
5. Fix letter case
| Function | Result |
|---|---|
=UPPER(A2) | ALL CAPS |
=LOWER(A2) | all lower |
=PROPER(A2) | Each Word Capitalised |
With accented and special characters check the result.
6. Split and join text
If first and last name are in one cell use Flash Fill (Ctrl + E) or Text to Columns. To join, =A2&" "&B2 is enough (see our text splitting guide).
7. Bulk fixes with Find and Replace
Ctrl + H: bring variants such as "Ltd.", "Ltd", "LTD" to one form. You can use wildcards (* and ?). Before replacing, use "Find All" to see how many cells are affected.
8. Manage blank cells
Select all blanks with F5 > Special > Blanks. You can fill them with "Unknown," fill them with the value above (type =A2 and Ctrl + Enter) or delete the row. Think about why the blank exists; zero and missing data are not the same.
9. Find wrong and outlying values
- Colour extreme values such as a negative age or a 1,000-year-old date with conditional formatting.
- Look at the smallest/largest values in a filter.
- For error values (#VALUE!, #N/A) find the source; instead of hiding them with IFERROR, fix the cause (see our Excel errors guide).
10. Build consistent categories
Link variants such as "New York," "new york," "NYC" to one list. Build a mapping table for the category and convert to the standard value with VLOOKUP (see our VLOOKUP guide). For new entries use a drop-down list (see our drop-down guide).
11. Repeatable cleaning with Power Query
If the same file arrives every month don't repeat the steps by hand. Bring it into Power Query with Data > From Table/Range; steps such as trim, change type and remove duplicates are recorded and re-applied on refresh (see our Power Query guide).
12. Validation and documentation
- Does the row count match before and after cleaning?
- Do totals match the source?
- Compare 20 sample rows by hand.
- Write the steps you took on a "Notes" sheet.
Quick reference table
| Problem | Fix |
|---|---|
| Extra spaces | TRIM, CLEAN |
| Duplicates | Remove Duplicates |
| Number as text | VALUE, Paste Special |
| Broken dates | Text to Columns |
| Case differences | UPPER, PROPER |
| Bulk fixes | Find and Replace |
| Repetitive job | Power Query |
Common mistakes
- Not backing up the raw data.
- Deleting the original column without converting formula results to values (#REF! error).
- Leaving merged cells; sorting and filtering break.
- Mistaking a blank for 0.
- Not documenting the cleaning.
Summary
TRIM for spaces, Remove Duplicates for repeats, VALUE for numbers, Text to Columns for dates, Power Query for automation: clean data is the first condition of reliable analysis.
Serkan Akyürek is the founder and author of toolrota; he writes step-by-step guides on Excel, AI, the cloud, personal finance and digital security.