Raw external data is almost never analysis-ready. This lesson teaches you a complete, repeatable workflow for splitting, cleaning, and normalizing imported data using Text to Columns, Flash Fill, and Excel's full suite of text transformation functions — with real-world scenarios and a hands-on exercise.

You've just received a CSV export from your CRM, a pipe-delimited flat file from a legacy ERP system, and a copy-paste from a web portal that crammed first names, last names, and job titles into a single column. Welcome to the real world of data work. In practice, the majority of time spent on any analysis isn't writing formulas or building charts — it's wrestling raw, messy, inconsistently formatted data into a shape that Excel can actually work with.
This lesson is about winning that battle efficiently. We'll cover the full toolkit for importing and cleaning external data: Text to Columns for splitting delimited and fixed-width data, Flash Fill for pattern-based transformations, and a suite of text functions and structural techniques that handle the scenarios those two tools can't. By the end, you'll have a repeatable workflow for taking raw data from nearly any source and turning it into clean, structured, analysis-ready information.
What you'll learn:
You should already be comfortable navigating Excel's interface and ribbon, writing basic formulas with cell references, and understand the difference between relative and absolute references. If you need a refresher on any of those, see Cell References Explained: Relative, Absolute, and Mixed References in Excel and Excel Interface Mastery: Advanced Ribbon, Quick Access Toolbar, and Keyboard Shortcuts for Data Professionals before continuing.
Before we touch any tool, let's talk about why external data is so consistently messy. Most data originates in systems that weren't designed with Excel in mind — databases, SaaS platforms, legacy software — and the export formats reflect those systems' internal logic, not yours.
Here are the four most common structural problems you'll encounter:
1. Multiple values crammed into one column. A database might store a full address in a single field: "123 Main St, Springfield, IL 62701". That's three or four distinct data points (street, city, state, zip) that you'll need to analyze separately.
2. Fixed-width exports. Older enterprise systems pad every field to a fixed character width, producing lines like "SMITH JOHN IL 62701" where the columns are positional, not delimited.
3. Non-printing characters and encoding issues. Data copied from web pages or exported from certain systems often contains invisible characters — line breaks, carriage returns, non-breaking spaces — that make cells appear identical but cause formulas to fail silently.
4. Inconsistent formatting within a column. Phone numbers in ten different formats, dates stored as text strings, numbers stored as text (causing SUM to return 0), capitalization all over the map.
Your cleaning workflow needs to address all of these, usually in sequence: first import and split, then clean and normalize, then validate.
Text to Columns is your primary tool for splitting one column of data into many. It lives on the Data tab in the Data Tools group. The wizard walks you through two file types: delimited (where a specific character separates each field) and fixed-width (where columns are defined by character position).
Imagine you've imported a CSV file but Excel loaded the entire row into column A instead of splitting it. Each cell looks like this:
EmployeeID,FirstName,LastName,Department,Salary
1001,Maria,Santos,Engineering,87500
1002,James,O'Brien,Marketing,72000
1003,Aisha,Patel,Engineering,91000
To split this:
|), tabs, or semicolons instead, check the appropriate box — or check Other and type the custom delimiter character.Warning
If you set the destination to column A itself with existing data in columns B, C, D, etc., Text to Columns will overwrite that data without warning. Always set your destination to a safe location or work on a copy of the data.
If you're splitting a column that contains ZIP codes, product codes, or ID numbers with leading zeros, Step 3 is where you save yourself. If you leave the column format as General, Excel will convert "07030" to 7030 — stripping the leading zero permanently. In Step 3 of the wizard, click that column in the preview and set its format to Text. This tells Excel to treat the value as a string and preserve every character.
Fixed-width is trickier because there's no delimiter to guide the split — you have to tell Excel exactly where each column starts and ends. Here's an example of fixed-width employee export data:
SANTOS MARIA ENGINR87500
OBRIEN JAMES MKTNG 72000
PATEL AISHA ENGINR91000
In this format, last name occupies characters 1–10, first name occupies 11–20, department occupies 21–27, and salary occupies 28–32.
Tip
For complex fixed-width files, download a sample of the data first and count character positions carefully. A simple trick: use a monospaced font (Courier New) in a text editor to align the columns visually before you start the wizard. This makes it much easier to identify where each field boundary falls.
Right after a Text to Columns split, run a quick quality check:
'87500 (with an apostrophe), it's stored as text. We'll fix this in a moment.Flash Fill is one of Excel's genuinely delightful features — it watches you transform data manually, recognizes the pattern, and applies it to the entire column. It was introduced in Excel 2013 and is available in all modern versions.
Flash Fill works on the column immediately to the left or within adjacent data. Here's how to use it:
You can also trigger it manually: type a couple of examples, then press Ctrl + E, or go to Data → Flash Fill.
Extracting first names from a full name column:
If column A contains "Santos, Maria" and you want just the first name in column B:
MariaJamesFlash Fill will extract the first name from every row.
Reformatting phone numbers:
Column A has phone numbers in various formats: 5551234567, 555-123-4567, (555) 123-4567. You want them all as (555) 123-4567:
(555) 123-4567 (formatted from the raw number in A2)Flash Fill will normalize the format for all rows — as long as the raw data has a consistent underlying structure (ten digits, in some form).
Combining columns:
If first names are in column A and last names are in column B, and you want LastName, FirstName in column C:
Santos, MariaWarning
Flash Fill is not a formula — it produces static values. If your source data changes, the Flash Fill output does not update automatically. Use it for one-time cleaning operations, and reach for text functions (covered next) when you need a dynamic, updatable transformation.
When Flash Fill struggles:
Flash Fill works by inferring a pattern from your examples. It can fail or produce incorrect results when:
In those cases, one or two extra examples usually help. If Flash Fill is consistently wrong, switch to text functions.
Key insight
Think of Flash Fill as a smart assistant, not an accountant. It's great for the 90% of rows that follow the pattern. Always scroll through the results and spot-check outliers before treating the output as clean data.
When Flash Fill can't handle it or you need a reproducible, formula-driven transformation, text functions are your precision instruments. Let's work through the most important ones with real scenarios.
Extra spaces are the most common data quality problem and the most invisible. " Maria Santos " and "Maria Santos" look identical in a cell but won't match in a VLOOKUP or COUNTIF.
=TRIM(A2)
TRIM removes all leading and trailing spaces, and collapses any runs of multiple internal spaces to a single space. This should be one of the first functions applied to any imported text column.
Data copied from web pages or exported from databases often contains non-printing characters — particularly CHAR(10) (line feed) and CHAR(13) (carriage return) — that TRIM won't touch.
=CLEAN(A2)
CLEAN removes all characters that correspond to ASCII values 1–31. Use it alongside TRIM:
=TRIM(CLEAN(A2))
This combination handles the vast majority of whitespace and invisible character problems.
Note
CLEAN doesn't handle non-breaking spaces, which have ASCII value 160. These come up frequently in web-scraped data. To remove them, add a SUBSTITUTE:
=TRIM(CLEAN(SUBSTITUTE(A2, CHAR(160), " ")))
This replaces non-breaking spaces with regular spaces, then TRIM cleans those up.
When you know exactly where your data lives within a string, positional functions are fast and reliable.
LEFT(text, num_chars) — extracts characters from the start:
=LEFT(A2, 3)
If A2 contains "ENG-2024-00147", this returns "ENG" — the category prefix.
RIGHT(text, num_chars) — extracts characters from the end:
=RIGHT(A2, 5)
Returns "00147" — the numeric ID portion.
MID(text, start_num, num_chars) — extracts from the middle:
=MID(A2, 5, 4)
Returns "2024" — the year portion starting at character 5, extracting 4 characters.
These work beautifully for structured codes — product SKUs, account numbers, file naming conventions — where the structure is always the same length.
Fixed positions break down when field lengths vary. If your data has "Maria Santos" in one row and "James O'Brien-McKenna" in another, you can't use LEFT(A2, 5) to get the first name reliably. Instead, find the space dynamically:
=LEFT(A2, FIND(" ", A2) - 1)
FIND returns the character position of the first space. Subtracting 1 gives us the position of the last character before the space — exactly the length of the first name.
For the last name:
=MID(A2, FIND(" ", A2) + 1, LEN(A2))
This starts one character after the space and extracts everything to the end of the string.
FIND vs SEARCH: FIND is case-sensitive. SEARCH is case-insensitive. For most data cleaning purposes, SEARCH is safer.
Real names have edge cases: double spaces, hyphenated last names, names with particles like "de la Cruz." For a more robust last name extraction that handles multiple spaces:
=TRIM(MID(A2, FIND(" ", TRIM(A2)) + 1, LEN(A2)))
The nested TRIM inside FIND handles leading spaces before finding the delimiter. The outer TRIM cleans up any trailing spaces in the result.
SUBSTITUTE is the formula equivalent of Find and Replace. It's more powerful than it looks.
Removing a specific character:
=SUBSTITUTE(A2, "-", "")
Converts "555-867-5309" to "5558675309".
Replacing the nth occurrence only:
=SUBSTITUTE(A2, "-", "", 2)
Removes only the second hyphen. This fourth argument is the instance number — incredibly useful when you have structured strings like "ENG-2024-00147" where you want to remove only the last hyphen.
Normalizing inconsistent delimiters:
=SUBSTITUTE(SUBSTITUTE(A2, ";", ","), " , ", ",")
This chains two SUBSTITUTEs: first replacing semicolons with commas, then cleaning up any space-comma combinations.
When you need to combine a number or date with text, you'll hit the classic problem: "Order date: " & A2 returns "Order date: 45678" instead of "Order date: January 15, 2025". The TEXT function solves this:
="Order date: " & TEXT(A2, "MMMM D, YYYY")
TEXT converts a number or date to a string using a format code. The format codes are the same ones you use in cell formatting dialogs. Some useful ones:
=TEXT(A2, "MM/DD/YYYY") ' → "01/15/2025"
=TEXT(A2, "YYYY-MM-DD") ' → "2025-01-15" (ISO format for databases)
=TEXT(A2, "$#,##0.00") ' → "$87,500.00"
=TEXT(A2, "000000") ' → "001234" (zero-padded ID numbers)
For more detail on date and text function patterns like these, see Working with Dates, Times, and Text Functions in Excel.
Inconsistent casing causes lookup failures just like extra spaces do. "engineering", "Engineering", and "ENGINEERING" are three different strings to Excel.
=UPPER(A2) ' → "MARIA SANTOS"
=LOWER(A2) ' → "maria santos"
=PROPER(A2) ' → "Maria Santos"
Warning
PROPER has a known quirk — it capitalizes the letter after any non-letter character. So "o'brien" becomes "O'Brien" (correct), but "mcdonald" becomes "Mcdonald" instead of "McDonald". For names with unusual capitalization patterns, PROPER is a good 95% solution but requires manual review.
When numbers are imported as text (you'll see them left-aligned in cells, and SUM will return 0), you need VALUE:
=VALUE(A2)
If A2 contains "87500" stored as text, VALUE(A2) returns the number 87500. You can also force the conversion with arithmetic:
=A2 * 1
=A2 + 0
=--A2
The double-negative (--) is a common shorthand that negates twice, effectively converting text to number. Any of these work — VALUE is the most readable.
Tip
A quick way to spot text-stored numbers in a large dataset: select the column and check the status bar at the bottom of the screen. If SUM is missing from the status bar (only COUNT appears), you're looking at text, not numbers. Real numbers will show both COUNT and SUM.
Let's put all of this together with a realistic scenario. You've received a flat-file export from a point-of-sale system. Each row in column A looks like this:
2025-01-15|1001|Santos, Maria|ENG| 87500.00 |Y
2025-01-16|1002|O'Brien, James|MKT| 72000.00 |N
2025-01-17|1003|Patel, Aisha|ENG| 91000.00 |Y
You need: separate date, ID, last name, first name, department, salary (as a number), and active status columns.
Step 1: Text to Columns to split by pipe delimiter
Select column A, Data → Text to Columns, Delimited, pipe character as delimiter. Set the date column to Date (YMD) format, and salary to General. Result: seven columns of raw data.
Step 2: Clean the name column (now in column C)
The name is in "Last, First" format. In a helper column:
' Last name (everything before the comma)
=TRIM(LEFT(C2, FIND(",", C2) - 1))
' First name (everything after the comma and space)
=TRIM(MID(C2, FIND(",", C2) + 2, LEN(C2)))
Step 3: Clean the salary column (now in column E)
The salary has leading and trailing spaces. After Text to Columns, it may have come through as text:
=VALUE(TRIM(E2))
Step 4: Normalize the department codes
The department codes are inconsistent — let's standardize to full names using IF or a lookup approach. Since we're treating this as a cleaning exercise, a SUBSTITUTE chain works for simple cases:
=SWITCH(TRIM(D2),
"ENG", "Engineering",
"MKT", "Marketing",
"FIN", "Finance",
"Unknown")
Step 5: Apply TRIM and CLEAN to all text columns
Even columns that look clean may have invisible characters. Wrap each text column's reference in TRIM(CLEAN(...)) as a final pass.
Step 6: Paste values, replace the originals
Once your helper columns are clean and validated, copy them, paste as Values Only (Ctrl + Shift + V → Values, or Paste Special → Values), and replace the original raw columns. Delete the intermediate helper columns.
Tip
Before deleting any raw data or helper columns, do a final spot-check: sort each cleaned column and look at the top and bottom ten values. Outliers — extremely long strings, blank values, suspicious numbers — cluster at the extremes and are easy to catch this way.
This kind of structured cleaning workflow connects naturally to the next step in your analysis: once data is clean and consistently formatted, you can convert it to a proper Excel Table and use structured references throughout your workbooks. See Advanced Excel Tables: Sorting, Filtering, and Structured Data Architecture for Data Professionals for how to build that foundation, and Essential Excel Functions: Master SUM, AVERAGE, COUNT, IF, and COUNTIF for Data Analysis to start analyzing the clean data immediately.
The Scenario: Your company's IT department has exported user account data from Active Directory. The file is a pipe-delimited text file, and the data looks like this when pasted into Excel column A:
jsmith|John Smith|IT Dept|555-867-5309|new york|2024-03-15|1
alopez|Anna Lopez|HR| (555) 246-8101 |chicago|2023-11-02|0
bpatel|Bhavesh Patel|engineering|555.333.7722|san francisco|2024-07-20|1
mwilson|Marcus Wilson|IT Dept|5554449999|NEW YORK|2023-05-10|1
Your task:
Use Text to Columns to split the pipe-delimited data into separate columns. Name your columns: Username, FullName, Department, Phone, City, StartDate, Active.
Use Flash Fill to extract first names and last names from the FullName column into two separate columns.
Write formulas to:
(555) 867-5309 — this is harder than it looks because the raw data has three different formats. Hint: use SUBSTITUTE to strip all non-digit characters first, then use LEFT, MID, and RIGHT to rebuild the formatted number.Identify and fix at least one text-stored number in the dataset.
After cleaning, select all cleaned data and format it as an Excel Table.
Challenge: The phone normalization formula is the most complex piece. The approach is:
SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(D2, "-", ""), ".", ""), "(", ""), ")", "") — chain SUBSTITUTEs for each non-digit character, then trim spaces."(" & LEFT(cleaned,3) & ") " & MID(cleaned,4,3) & "-" & RIGHT(cleaned,4)"Text to Columns overwrote my data." You forgot to set the destination before clicking Finish. Always check the Destination field in Step 3 of the wizard. Set it to an empty area — if your data starts in A1, set destination to C1 or to a new sheet entirely.
"Flash Fill gave me wrong results for some rows." Flash Fill inferred a pattern that doesn't hold for all rows. Check rows where the source data differs structurally from your examples — extra spaces, different name formats, missing values. Provide additional examples in the Flash Fill column or switch to a formula approach.
"VLOOKUP returns #N/A even though I can see the value exists."
Almost always a data type mismatch or whitespace issue. The lookup value in one column is a number; the same value in the other column is text. Or there are trailing spaces in one. Apply TRIM(CLEAN(...)) to both columns, and use VALUE() to normalize numeric types. For more detail on this kind of lookup debugging, see VLOOKUP vs XLOOKUP: The Definitive Comparison.
"My FIND formula returns #VALUE! for some rows." FIND throws an error when the character you're searching for doesn't exist in the string. Wrap it in IFERROR to handle missing delimiters gracefully:
=IFERROR(LEFT(A2, FIND(" ", A2) - 1), A2)
This returns the whole string if no space is found — reasonable behavior for single-name entries. Learn more defensive formula techniques in Master Error Handling in Excel: IFERROR, IFNA & Professional Debugging Techniques.
"PROPER capitalized words inside parentheses or after apostrophes incorrectly." Known behavior. After PROPER, run a targeted SUBSTITUTE to fix predictable problems:
=SUBSTITUTE(PROPER(A2), "'S ", "'s ")
For complex cases, consider whether you need a full lookup table of canonical names rather than algorithmic capitalization.
"Numbers are still left-aligned after I applied VALUE()." Check whether the column has been formatted as Text at the cell-formatting level. Column formatting overrides what Excel displays — a number in a Text-formatted cell will still appear left-aligned. Select the cells, change the format to General or Number, then press F2 and Enter in a few cells to re-evaluate. For a whole column: select it, Data → Text to Columns → Finish (just clicking Finish with the column selected forces Excel to re-evaluate all the cells).
"TRIM isn't removing all the spaces I can see."
You're likely dealing with non-breaking spaces (CHAR 160) rather than regular spaces (CHAR 32). Use the extended formula: =TRIM(CLEAN(SUBSTITUTE(A2, CHAR(160), " "))).
Let's take stock of what you now have in your toolkit:
The biggest shift in mindset this lesson asks for is treating data cleaning as structured engineering, not ad-hoc fiddling. Document your steps, keep the raw data in a separate sheet or column, and build your cleaning formulas in adjacent helper columns before replacing originals. That approach makes your work auditable, reproducible, and much easier to fix when something unexpected turns up.
From here, your natural next move is putting this clean data to work. If you're building summary reports, PivotTables from Scratch: Summarize Any Dataset in Minutes will show you how to slice and aggregate clean data rapidly. If your analysis involves multi-criteria calculations across the cleaned dataset, Master SUMIFS, COUNTIFS, and AVERAGEIFS: Multi-Criteria Calculations in Excel is the right follow-on. And if you find yourself cleaning the same files weekly, Introduction to VBA: Write Your First Excel Macro and Automate Repetitive Tasks will show you how to automate your entire cleaning workflow with a single button click.
Clean data is the foundation everything else is built on. Master this, and every analysis you do downstream becomes faster, more reliable, and more trustworthy.