How to Separate Strings in Excel
In this article
Yes, you can split text apart in Excel using the built-in Text to Columns tool, the LEFT, RIGHT, and MID functions, or the more advanced TEXTSPLIT function available in newer versions. This process takes a single cell containing multiple words or values—like a full name, an address, or a product code with a category—and breaks it into separate columns so you can sort, filter, or analyze the data independently. Excel offers several ways to achieve this, depending on whether you are splitting by a specific character like a comma or space, or by a fixed number of characters.
What You'll Need
- A computer with Microsoft Excel installed (Excel for Microsoft 365, Excel 2021, or newer is recommended for the TEXTSPLIT function).
- A spreadsheet with the data you wish to separate. The data should ideally be in a single column, though the process works on ranges as well.
- A basic understanding of Excel formulas or the willingness to use the ribbon interface. No external tools or plugins are required.
Step-by-Step
Here are the three most common methods to separate strings in Excel, ranging from the easiest non-formula method to the most powerful formula-based approach.
Method 1: Using Text to Columns (The Non-Formula Way)
This is the fastest method if you want to split data without writing any formulas. It works perfectly for fixed delimiters like commas, spaces, or tabs.
- Select the cells: Click and drag to highlight the column (or columns) of data that contains the strings you want to separate. You can select a single cell, and Excel will try to detect the range, or select a specific range if you only want to split a subset of data.
- Open the tool: Navigate to the Data tab in the ribbon at the top of the window. Look for the "Data Tools" group and click on Text to Columns. A wizard will appear to guide you through the process.
- Choose the delimiter: In the first step of the wizard, select the Delimited option and click Next. On the next screen, you will see options for the type of separator. Check the box next to the delimiter that separates your data, such as Tab, Comma, or Space. If your data uses a custom character like a hyphen or slash, check "Other" and type that character into the box. If you are unsure, you can click "Test" to see how Excel interprets the split before you commit.
- Set column formats: In the third step of the wizard, you can specify the format for each resulting column. By default, Excel sets columns to General, but you may want to format dates or numbers differently. If you only want to split the data and leave the rest of the sheet untouched, ensure you have enough empty columns to the right of your selection to accommodate the split data.
- Finish: Click Finish to apply the changes. Excel will instantly rearrange your data, placing the separated values into the adjacent columns.
Method 2: Using LEFT, RIGHT, and MID Functions (Split by Position)
This method is ideal when you know exactly how many characters are in each part of the string and want to extract them by position. For example, if you have a 10-character product code where the first 4 are the category, the next 3 are the style, and the last 3 are the size.
- Identify the string: Assume your text string is in cell A2 and you want to extract the first 4 characters.
- Use the LEFT function: In an adjacent cell (e.g., B2), type the formula
=LEFT(A2, 4). This function takes the first argument as the text string and the second as the number of characters to return. Press Enter to see the result. - Use the RIGHT function: If you need to extract characters from the end of the string, use the RIGHT function. For example, to get the last 3 characters from the same string in A2, type
=RIGHT(A2, 3)in cell C2. - Use the MID function: To extract characters from the middle of the string, use the MID function. The syntax is
=MID(text, start_num, num_chars). For instance, to get characters 5 through 10 from A2, you would type=MID(A2, 5, 6). The start number is the position where you want to begin, and the num_chars is the length of the substring you want to extract. - Drag the formulas: Click the bottom-right corner of the cell with your formula and drag it down to apply the same logic to all rows in your dataset.
Method 3: Using the TEXTSPLIT Function (The Modern Way)
If you are using Excel for Microsoft 365 or Excel 2021, the TEXTSPLIT function is a powerful tool that splits a text string into an array of values and spills them across adjacent cells automatically. This is often superior to the Text to Columns wizard because it is dynamic and updates when your source data changes.
- Prepare your data: Ensure you have a clean dataset in a column, for example, items separated by a comma in cell A2: "Apple, Banana, Cherry".
- Enter the formula: Click an empty cell where you want the split data to start. Type the formula
=TEXTSPLIT(A2, ","). The first argument is the text string, and the second is the delimiter. - Allow for spill: As you press Enter, Excel will automatically fill the adjacent cells to the right with the separate words. This is known as "dynamic array" behavior. If you have multiple delimiters (e.g., commas and spaces), you can include them all in the second argument as an array constant:
=TEXTSPLIT(A2, {",", " "}). - Handle errors: If you encounter a
#SPILL!error, it usually means there is already data in the cells where the result is trying to appear. Clear those cells, and the formula will update.
Common Mistakes
- Leaving the split columns too short: When using Text to Columns, if you don't have enough empty columns to the right of your selection, Excel will overwrite existing data. Always check the destination range before clicking Finish.
- Ignoring leading/trailing spaces: If your data is separated by spaces but there are extra spaces between words (e.g., "John Doe" instead of "John Doe"), the split might result in empty columns. You can use the TRIM function (
=TRIM(A2)) on your source data first to clean up the spacing before splitting. - Misunderstanding the delimiter: In the Text to Columns wizard, confusing a comma (,) with a period (.) can lead to incorrect splits. Double-check the Test box to ensure the wizard sees the separator correctly.
- Using the wrong function for fixed width: If you are splitting data by a fixed number of characters (like a barcode), the Text to Columns wizard is the correct tool. Using LEFT or MID requires you to manually calculate the start and end positions for each split, which can be error-prone.
Tips
- Use the Flash Fill feature: If you just want to separate a single column of data and don't want to remember formulas, type the first correctly separated value manually in the adjacent column (e.g., type "Apple" in B2). Start typing the second value in B3, and Excel will likely recognize the pattern and offer to fill the rest. Press Ctrl + E to accept the suggestion.
- Combine functions for complex splits: You can nest functions inside one another. For example, if you want to extract text before the first space and then the text after that space, you can use a combination of SEARCH and LEFT or RIGHT functions to dynamically find the delimiter position.
- Text to Columns is one-way: Once you use Text to Columns, the original data in the source column remains. The split data is written to new columns. If you want to keep the original single column and have separate data elsewhere, you must create a new column for the split results first.
- Check for special characters: Sometimes delimiters are not visible characters but non-breaking spaces or line breaks. In the Text to Columns wizard, look for the "Other" option and try typing a line break (Alt + Enter) or a non-breaking space if the standard space option isn't working.
Troubleshooting
If your data is not splitting as expected, follow these steps to diagnose the issue.
The data is not splitting at all.
This usually happens when the delimiter you selected does not match the data. For example, if your data is "John, Doe" but you selected the space delimiter, Excel will treat the whole string as one item. Go back to the Text to Columns wizard and check the "Other" box to see if a different character is separating your data.
I am getting #VALUE! errors in my formulas.
This error in the LEFT, RIGHT, or MID functions typically means the cell you are referencing is empty or contains non-text data (like a number formatted as text). Ensure that the cell A2 actually contains text and not a blank cell. You can use the ISTEXT() function to check this.
The TEXTSPLIT formula returns only one value.
If you are using the TEXTSPLIT function and it is only returning the first item, check your delimiter. If you are using a comma, ensure that there are no spaces after the comma in your source data (e.g., "Apple, Banana" is fine, but "Apple, Banana" might be interpreted as two separate items). Also, ensure you are using a comma as the second argument, not a period.
My data is being split into too many columns.
This often occurs when the source data contains multiple consecutive delimiters (e.g., "Apple,, Banana"). The Text to Columns wizard may interpret the empty space between the two commas as a valid column. You can clean this by using the TRIM function on your source data before splitting to remove extra spaces.
Flash Fill is not working.
Flash Fill requires a clear pattern to recognize. If you type the first value but the next cell doesn't suggest the second, try typing the first two values correctly to give Excel a stronger pattern. Also, ensure that the data in the column is consistent; mixed formats (like names and dates in the same column) can confuse the pattern recognition.
Frequently Asked Questions
Can I split a string by a character that appears multiple times?
Yes, the Text to Columns wizard and the TEXTSPLIT function handle multiple occurrences. If you have a string like "A-B-C" and you split by the hyphen, you will get three columns: "A", "B", and "C". The wizard simply treats every instance of the delimiter as a split point.
How do I split a full name into First and Last names?
The easiest way is to use Text to Columns and select the Space delimiter. This will split the name into as many columns as there are words. You can then delete the middle names or suffixes (like "Jr.") manually. For a more precise formula approach, you can use the LEFT and FIND functions together to extract only the first name.
What is the difference between Text to Columns and Flash Fill?
Text to Columns is a rigid tool that splits data based on a specific rule you set (like a comma or space). Flash Fill is a pattern-matching tool that learns from your examples. Flash Fill is often more flexible for irregular data, while Text to Columns is faster and more reliable for consistent, structured data.
Can I split text into rows instead of columns?
Yes, you can. The process is similar, but you would need to transpose the data or use a different method like the FILTERXML function with an XML parser to split data into rows. However, the most common workflow for Excel users is to split columns, which is supported natively by all the methods described above.
Does splitting data delete the original information?
No. The Text to Columns feature writes the separated data into new columns and leaves the original column unchanged. However, it is good practice to save a copy of your original spreadsheet before running any data manipulation tools, just in case you accidentally overwrite something.
Why is my TEXTSPLIT not working in an older version of Excel?
The TEXTSPLIT function was introduced in Excel 2021 and is part of the dynamic array suite. It is not available in older versions like Excel 2019 or Excel 2016. Users of these versions must use the Flash Fill feature or the legacy Text to Columns wizard.