Text to Columns is an amazing feature in Excel that deserves a lot more credit than it usually gets.
As it’s name suggests, it is used to split the text into multiple columns. For example, if you have a first name and last name in the same cell, you can use this to quickly split these into two different cells.
This can be really helpful when you get your data from databases or you import it from other file formats such as Text or CSV.
In this tutorial, you’ll learn about many useful things that can be done using Text to Columns in Excel.
This Tutorial Covers:
To access Text to Columns, select the dataset and go to Data → Data Tools → Text to Columns.
This would open the Convert Text to Columns Wizard.
This wizard has three steps and takes some user inputs before splitting the text into columns (you will see how these different options can be used in examples below).
To access Text to Columns, you can also use the keyboard shortcut – ALT + A + E.
Now let’s dive in and see some amazing stuff you can do with Text to Columns in Excel.
Suppose you have a dataset as shown below:
To quickly split the first name and the last name and get these in separate cells, follow the below steps:
This would instantly give you the results with the first name in one column and last name in another column.
Text to Columns allows you to choose your own delimiter to split text.
This can be used to split emails addresses into usernames and domain names as these are separated by the @ sign.
Suppose you have a dataset as shown below:
These are some fictional email ids of some cool superheroes (except myself, I am just a regular wasting-time-on-Netflix kinda guy).
Here are the steps to split these usernames and domain names using the Text to Columns feature.
This would split the email address and give you the first name and the last name in separate cells.
If you work with web URLs, you may sometimes need to know the total number of unique root domains.
For example, in case of http://www.google.com/example1 and http://google.com/example2 , the root domain is the same, which is www.google.com
Suppose you have a dataset as shown below:
Here are the steps to get the root domain from these URLs:
This would split the URL and give you the root domain (in the third column as there were two forward slashes before it).
Now if you want to find the number of unique domains, just remove the duplicates.
Note: This works well when you have all the URLs that have http:// in the beginning. If it doesn’t, then you will get the root domain in the first column itself. A good practice is to make these URLs consistent before using Text to Columns.
If you get your data from databases such as SAP/Oracle/Capital IQ, or you import it from a text file, there is a possibility that the date format is incorrect (i.e., a format that Excel does not consider as date).
There are only a couple of formats that Excel can understand, and any other format needs to be converted into a valid format to be used in Excel.
Suppose you have dates in the below format (which are not in the valid Excel date format).
Here are the steps to convert these into valid date formats:
This would instantly convert these invalid date formats into valid date formats that you can use in Excel.
Sometimes when you import data from databases or other file formats, the numbers are converted into text format.
There are several ways this can happen:
The problem with this is that these numbers (which are in text format) are ignored by Excel functions such as SUM and AVERAGE.
Suppose you have a dataset as shown below where the numbers are in the text format (note that these are aligned to the left).
Here are the steps to use Text to Columns to convert text to numbers
This would convert these numbers back into General format that can now be used in formulas.
Sometimes you may need to extract the first few characters of a string.
These could be the case when you have transactional data, and the first five characters (or any other number of characters) represent a unique identifier.
For example, in the data set shown below, the first five characters are unique to a product line.
Here are the steps to quickly extract the first five characters from this data using Text to Columns:
This would split your data set and give you the first five characters of each transaction id in one column and rest all in the second column.
Note: You can set more than one vertical line as well to split the data into more than 2 columns. Just click anywhere in the Data Preview area and drag the cursor to set the divider.
While this is not something that may encounter often, but sometimes, you may find yourself fixing the numbers with trailing minus signs and making these numbers negative.
Text to Columns is the perfect way to get this sorted.
Suppose you have a dataset as shown below:
Here are the steps to convert these trailing minuses into negative numbers:
This would instantly place the minus sign from the end of the number of the beginning of it. Now you can easily use these numbers in formulas and calculations.
You May Also Like the Following Excel Tutorials: