Excel Split Text with Delimiter: Step-by-Step
The calculator for this page is switched off while it is checked. The formula is below, and the worked example in the article shows how to use it by hand.
Excel’s Text-to-Columns and Flash Fill features let you split text by a delimiter (like a comma, space, or hyphen) into separate columns or rows. You select the cells, choose the delimiter, and Excel divides the text at each occurrence. This article explains both methods, when to use each, and how to handle common problems.
Formula
The formula to count how many parts a delimiter creates is:
Number of parts = (LEN(text) – LEN(SUBSTITUTE(text, delimiter, “�))) / LEN(delimiter) + 1
- text – the cell containing the string you want to split (e.g., A2).
- delimiter – the character or characters that separate the parts (e.g., “,� or “;�).
- LEN() – returns the number of characters in a string.
- SUBSTITUTE() – replaces every instance of the delimiter with an empty string.
The formula subtracts the length of the text after removing all delimiters from the original length, then divides by the delimiter’s length to get the number of delimiters. Adding 1 gives the number of parts.
Worked Example
Using the calculator’s defaults: text = “apple,banana,cherry�, delimiter = “,�
- LEN(“apple,banana,cherry�) = 19
- LEN(SUBSTITUTE(“apple,banana,cherry�, “,�, “�)) = LEN(“applebananacherry�) = 17
- Number of delimiters = (19 – 17) / 1 = 2
- Number of parts = 2 + 1 = 3
The result is 3, which matches the three fruit names. This formula is useful when you need to know how many columns a split will produce before you do it.
Using Text-to-Columns (the Classic Method)
Text-to-Columns is Excel’s built-in tool for splitting text by a delimiter. It works in both Windows and Mac versions of Excel.
- Select the column or range of cells that contain the text you want to split.
- Go to the Data tab and click Text to Columns.
- Choose Delimited and click Next.
- Check the delimiter that matches your data (comma, tab, semicolon, space, or “Other� to type a custom one).
- Click Next, then choose the destination cell (default is the top-left of the selection).
- Click Finish.
Excel will overwrite the original data with the split parts. If you want to keep the original, choose a different destination cell in step 5 (e.g., $C$1).
Using Flash Fill (the Quick Method)
Flash Fill automatically detects patterns and fills in data without formulas. It’s ideal for splitting text when the delimiter is consistent and you want to extract specific parts.
- In the column next to your data, type the first part you want (e.g., type “apple� in B2).
- Press Enter and then start typing the second row’s value (e.g., “banana� in B3).
- Excel will show a preview of the remaining values in light gray.
- Press Enter to accept the Flash Fill.
You can also trigger Flash Fill manually by clicking the Flash Fill button on the Data tab or pressing Ctrl+E (Windows) / Cmd+E (Mac). Flash Fill works best when the pattern is simple and consistent; if your data has varying formats, it may not guess correctly.
How to Choose Between Text-to-Columns and Flash Fill
Both methods split text, but they suit different situations.
- Text-to-Columns – Use when you need to split an entire column into multiple columns at once, especially if the delimiter is consistent and you want to control the output format (e.g., treating consecutive delimiters as one).
- Flash Fill – Use when you only need to extract one or two parts, or when the delimiter varies but the pattern is recognizable (e.g., extracting the last name from “Doe, John� vs “John Doe�).
- Formulas – Use when you want the split to update automatically if the original text changes, or when you need to split into rows rather than columns.
For splitting into rows (instead of columns), you can use the Power Query “Split Column by Delimiter� option, or use a formula with TEXTSPLIT if you have Excel 365.
Common Problems and How to Fix Them
Users often run into a few recurring issues when splitting text.
- Data spills into adjacent cells that already contain data. Excel will ask if you want to overwrite them. Always choose a blank area or move existing data first.
- Multiple consecutive delimiters (e.g., “apple,,banana�). In Text-to-Columns, check the “Treat consecutive delimiters as one� option. In Flash Fill, it may not handle this correctly.
- Delimiter appears inside quotes (e.g., “apple, banana�, cherry). Text-to-Columns has a “Text qualifier� setting (default is double quotes) that tells Excel to ignore delimiters inside quotes. Set it to “ or ‘ as needed.
- Split result is in scientific notation or changes number formatting. In step 5 of Text-to-Columns, choose “Text� as the column data format to prevent Excel from converting values like “00123� to “123�.
- Flash Fill doesn’t trigger. Make sure you type the example in a column that is directly adjacent to the original data, and that there are no blank columns in between.
Splitting with Formulas (for Dynamic Results)
If you want the split to update automatically when the original text changes, use Excel’s text functions. In Excel 365, the TEXTSPLIT function is the easiest:
=TEXTSPLIT(A2, ",")
This spills the parts into adjacent cells horizontally. For older Excel versions, you can use a combination of LEFT, MID, and FIND to extract each part manually. For example, to get the first part before a comma:
=LEFT(A2, FIND(",", A2) - 1)
To get the second part (between the first and second commas):
=MID(A2, FIND(",", A2) + 1, FIND(",", A2, FIND(",", A2) + 1) - FIND(",", A2) - 1)
These formulas become unwieldy with many parts, so Text-to-Columns or TEXTSPLIT is usually better.
Frequently Asked Questions
How do I split text by a space in Excel?
In Text-to-Columns, select Delimited and check Space as the delimiter. If your text has multiple spaces, enable “Treat consecutive delimiters as one�. Flash Fill also works by typing the first word and letting it auto-fill.
Can I split text into rows instead of columns?
Yes. Use Power Query: go to Data > From Table/Range, select the column, then Split Column > By Delimiter, and choose “Rows� as the split option. Alternatively, in Excel 365, use TEXTSPLIT with the # sign to spill vertically, but the easiest is Power Query.
Why is my Text-to-Columns not splitting correctly?
Check if the delimiter you selected matches the one in your data (e.g., semicolon vs comma). Also ensure the “Text qualifier� is set correctly if your data contains quotes. If you have leading/trailing spaces, they can interfere – use the “Treat consecutive delimiters as one� option or trim spaces first.
How do I split text by a custom delimiter like a hyphen or newline?
In Text-to-Columns, choose Other and type the hyphen. For newlines, you can copy the line break character (Ctrl+J in Windows) into the “Other� field. In Power Query, you can select “Custom� and enter the delimiter.
Does splitting text affect the original data?
Text-to-Columns overwrites the original cells unless you specify a different destination. Flash Fill adds new data in the adjacent column and does not alter the original. Formulas create new output without touching the source.
Can I undo a split?
Yes, press Ctrl+Z (Windows) or Cmd+Z (Mac) immediately after the split to undo it. If you close the file, you cannot undo, so consider saving a backup before splitting.
Related
Formula used
in t | Text to split | - | "apple,banana,cherry" | 0 in d | Delimiter | - | "," | 0 out n | Number of parts | - | (len(t)-len(substitute(t,d,"")))/len(d)+1 | 0
Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.