There are many circumstances where we receive information with multiple data points inside a single cell. This often occurs when the data’s original intention is slightly different from how we intend to use it. In these circumstances, we often need to split a cell into its constituent parts. This post will look at solving this problem and learn how to split cells in Excel.
The scenario we are trying to solve is; we want to split an individual’s full name into the first name and last name components.
If we have ten cells, it’s not a big problem; we can do that manually by entering each value into a separate column. But if we have hundreds or thousands of cells, we need to find another way. Thankfully we can turn to a variety of Excel features.
Download the example file
I recommend you download the example file for this post. Then you’ll be able to work along with examples and see the solution in action, plus the file will be useful for future reference.
Download the file: 0051 Split cells in Excel.xlsx
Watch the video
In all our solutions, we will be using the following data set.
In this post, we are covering 4 possible options. Depending on your data, one method may lead to better results than others. The lower the level of data consistency, the harder the process becomes.
Split cells using Text to Columns Wizard
Text to columns is a feature in Excel that hides in plain sight. It’s on the ribbon as an icon, but unless you know it’s there and what it does, you may not have used it before.
The steps to split a cell into multiple columns with Text to Columns are:
- Select the cell or cells containing the text to be split
- From the ribbon, click Data > Data Tools (Group) > Text to Columns
- The Convert Text to Columns Wizard dialog box will open
- Select the Delimited option. This allows us to split the text at each occurrence of specific characters. In our case, the space character is our delimiter. Click Next.
- Step 2 in the Convert Text to Columns Wizard opens. In the Delimiters group, select the relevant option for your scenario. I have selected Space for this scenario. Click Next.
- Finally, in Step 3 of the Text to Columns Wizard, we specify the format for the result. As we are using text, the General format is a reasonable option. Select a Destination cell where to output the result. I have selected Cell B2. Click Finish.
That’s it. Just a few clicks and we’re done 🙂
Our range should now be perfectly split into multiple columns.
Note about Text to Columns
Text to columns is not a dynamic feature; if the source cells change, we need to re-run the process by going back to Data > Data Tools (Group) > Text to Columns.
Text to columns works best on cells that are in a consistent format. For example, if one cell had 1 space, while others had 2 spaces, it may not provide the desired results.
Split cells using Flash Fill
Flash Fill is a fantastic feature that was introduced in Excel 2013. You may have already used it without even being aware of it. It is very easy to use for splitting cells in Excel with simple patterns.
It can run in two ways:
- In the background, Excel tries to find patterns in the text and automatically makes suggestions.
- Triggered by the user at specific times
For background execution:
- With the source cells on the left, type the text element we want to extract in the first row of the first column (cell B2 in the screenshot below).
Nothing will happen yet.
- Start typing the element of the text we want to extract from the second cell. Now Flash Fill jumps into action and makes recommendations:
- Press the Tab or Enter key to accept the recommended fill.
This gives us the first name.
Now let’s manually trigger Flash Fill to get the last name.
- With the source cells on the left, type the text element to be extracted into any single row.
- Select the cells in the range to be filled with values (cells C2 to C11 in our example), click Home > Fill (dropdown) > Flash Fill.
And we’re done. Both first name and last name have been separated into columns. I’ve shown the background and manual methods above; you can use either.
Note about Flash Fill
While Flash Fill in Excel is very good at identifying patterns, it will not always return the values you are expecting in more complex scenarios. There needs to be some logical pattern for it to find.
Flash Fill returns static values. If the source cells change, we need to re-run the process.
Flash Fill is also available in Data (tab) > Flash Fill
If Excel is unable to understand the pattern, it will return an error message.
Hopefully, you’ll agree that this future is any quick transformation we may want to make to the cells in Excel.
Formula Magic with Dynamic Arrays
Have you ever faced these spreadsheet scenarios?
- How can I use VLOOKUP to return all the matching items, not just the first?
- How can I sort my information using a formula, so I don’t have to keep clicking the sort button?
- How can I quickly create unique lists of items to use with my SUMIFS calculation?
- How can I stop copying down formulas every time my source data changes.
- How can I build a PivotTable-like report, but using formulas so I don’t have to click refresh ever again.
Well, I’m here to give you some good news. with dynamic arrays, all these can be achieved easily 🙂
Split cells using Power Query
Another option for splitting multiple cells in Excel is to use Power Query. This has been natively available since Excel 2016. Prior to that, there was an add-in for Excel 2010 and 2013.
First, let’s load our cells into the Power Query editor.
- Select any cell in the data set, then click Data (tab) > From Table/Range (or Data (tab) > From Sheet in newer versions of Excel) from the ribbon.
- If the selected cell is not part of an Excel table already, the Create Table box opens. Ensure the full range is selected, and my table has headers option is checked. Then click OK.
- The Power Query editor will open with all the data displayed.
- From the Power Query ribbon select Home > Split Column (drop-down) > By Delimiter.
- Depending on the complexity of your text, there are lots of options to split the contents of a cell by different positions. For our scenario, the Space character and each occurrence of the delimiter are good options. Click OK.
- In the data preview window, we now have the name split into two different columns.
- In the data preview window, Double click the header and change the headings to First and Last respectively.
- Now we need to get the data back into Excel. Click Home > Close & Load (drop-down) > Close & Load To…
- From the Import Data dialog box, select Table and choose where to load the information back to. In the example, I have selected an existing sheet at cell C1. Click OK.
The transformed data will now be loaded back into the cells in Excel.
Note about Power Query
If our source cells change or more names are added, we can simply click Data (tab) > Refresh All, to refresh the output.
This method will change the source cells into an Excel table even if you don’t want it to.
If splitting by delimiters is not powerful enough, Power Query can transform more complex strings using the Column from Examples feature.
Power Query provides a lot of advanced tools to handle more complex data manipulation. If you’ve not used Power Query much, then check out my Introduction to Power Query series.
Split cells using Excel formulas
In answering the question of how to split a cell in Excel, our final option is to use standard Excel formulas. These give us the ability to split the contents of a cell using any rules we can program into our formulas. While formulas are very powerful, they also require our skill rather than using a point-and-click interface.
Useful Excel functions to split cells
The most useful functions to split multiple cells are:
Returns the specified number of characters from the start of a text string.
=LEFT("Doris Green", 5)
The second argument of 5 is telling the function to return the first 5 characters of the text “Doris Green”.
Returns the specified number of characters from the end of a text string.
=RIGHT("Kathryn West", 4)
The second argument of 4 is telling the function to return the last 4 characters of the text “Kathryn West”.
MID returns the characters from the middle of a text string, given a starting position and length.
=MID("Ann Lewis", 5, 3)
The second argument represents the nth character to start from, and the last argument is the length of the string. From the text “Ann Lewis”, the 3 characters starting at position 5 are “Lew”.
Returns the number of characters in a text string.
There are 13 characters in the string (including spaces).
SEARCH returns the number of characters at which a specific character or text string is first found. SEARCH reads left to right and is not case sensitive.
=SEARCH(" ","Charles Bell",1)
The space character first appears in the 8th position of the string “Charles Bell”; therefore, the value returned is 8.
The last argument is optional; it provides the position to start searching from. If excluded, the count will start at the first character.
Note: FIND is the case-sensitive equivalent of the SEARCH function.
SUBSTITUTE replaces all existing instances of a text string with a new text string.
Result: Juan Wilson
The text string of Dix has been replaced with Wils. The last argument determines which instance to replace. In the formula above, it has replaced the 1st instance only. If we had excluded this argument, it would have replaced every instance.
Our scenario is reasonably simple, to split a cell into multiple columns we can use the LEFT, RIGHT, LEN and SEARCH functions. We can extract the first and last name as follows:
- SEARCH finds the space character’s position, which for the first record in the example cells of “Amaliya Allen” is the 8th position.
- We do not want the space character included in the string, so we minus 1 from the result to give us a value of 7.
- LEFT then extracts the first 7 characters of the text string.
- LEN finds the length of the text string, which for “Amaliya Allen” is 13.
- SEARCH finds the position of the space character, which is 8.
- 13 minus 8 provides us with the number of characters after the first space.
- RIGHT is then used to extract the characters after the space.
With these two formulas, it gets us back to the same result as we’ve had before; first name in Column B and last name in Column C:
Notes about using formulas
Formulas are the only option in this post that are fully dynamic. If the original text changes, the formula result updates automatically too.
Depending on the complexity of the text string to be split, these formulas can become quite complex.
With these 4 techniques, you have learned how to split cells in Excel. Each option has added more and more power to deal with complexity. Which option you choose comes down to your specific scenario. Familiarize yourself with all the options, and then you’ll be able to make the best decisions.
Get our FREE VBA eBook of the 30 most useful Excel VBA macros.
Automate Excel so that you can save time and stop doing the jobs a trained monkey could do.
By entering your email address you agree to receive emails from Excel Off The Grid. We’ll respect your privacy and you can unsubscribe at any time.
If you’ve found this post useful, or if you have a better approach, then please leave a comment below.
Do you need help adapting this to your needs?
I’m guessing the examples in this post didn’t exactly meet your situation. We all use Excel differently, so it’s impossible to write a post that will meet everybody’s needs. By taking the time to understand the techniques and principles in this post (and elsewhere on this site) you should be able to adapt it to your needs.
But, if you’re still struggling you should:
- Read other blogs, or watch YouTube videos on the same topic. You will benefit much more by discovering your own solutions.
- Ask the ‘Excel Ninja’ in your office. It’s amazing what things other people know.
- Ask a question in a forum like Mr Excel, or the Microsoft Answers Community. Remember, the people on these forums are generally giving their time for free. So take care to craft your question, make sure it’s clear and concise. List all the things you’ve tried, and provide screenshots, code segments and example workbooks.
- Use Excel Rescue, who are my consultancy partner. They help by providing solutions to smaller Excel problems.
Don’t go yet, there is plenty more to learn on Excel Off The Grid. Check out the latest posts: