Separating Text in Excel
Texts in Excel can appear in different ways. Maybe there is a text which is joined by some kind of symbol, or the text is like a first name and the last name.
There will be some point in our life where we will want those texts separated. The problem statement is explained above that we will come towards some sort of data where we need to separate those texts from one to another. But how do we separate those texts from one another? There is one very basic way to do it copy the desired text in each desired respective cell. Or, we can use some pre-given excel tools to do so.
How to Separate Text in Excel?
There are two methods to separate Texts in Excel:
- Using “Text to Columns in ExcelText To Columns In ExcelText to columns in excel is used to separate text in different columns based on some delimited or fixed width. This is done either by using a delimiter such as a comma, space or hyphen, or using fixed defined width to separate a text in the adjacent columns.“: which further has its own two bifurcations:
- Delimited: This feature splits the text, which is being joined by characters, Commas, Tabs, Spaces, Semicolon, or any other character such as a hyphen (-).
- Fixed Width: This feature splits the text, which is being joined with spaces with some certain width.
- Using Excel Formulas: We can use formulas like the Len in excelLen In ExcelThe Len function returns the length of a given string. It calculates the number of characters in a given string as input. It is a text function in Excel as well as an inbuilt function that can be accessed by typing =LEN( and entering a string as input. to calculate the length of the string and separate the values by knowing the position of the characters.
Let us learn these methods using examples.
Example #1 – Delimiter Method to Separate Text
First things first, where do we find this feature text to columns in excel. It is under the data Tab in the Data Tools section.
Consider the following data,
We want to separate the first name and the last name and have the contents of the last name in the B column.
Below are the steps of separating text in excel –
- To do this, select the column containing the data, i.e., A column.
- Under Data Tab in the Data Tools section, Click on Text To Columns.
- A dialog box appears for text to columns wizard.
- As we are going to use the delimiter method first, Select the delimited option and click on next and another dialog box appears.
- For the current data, our texts are separated in excel by spaces, so select the Space option as a delimiter ( By default, Excel selects Tab as a delimiter). Click on Next.
- We can see that our data preview that our texts are separated with first and last names. Click on Finish to see the result.
- We have successfully separated our excel text by using text to column delimiter method.
Example #2 – Using the Fixed Width Method to Separate Text
We already know where the option of text to the column is in Excel. It is in the Data Tab under the data tools section.
Now we consider the following data,
There is a survey company which is conducting a survey for the feedback of a restaurant. The users give their feedback as Good or Bad, but every response is saved by a timestamp, which means with every response, time is recorded, specific Data and time in Hours and minutes.
I need to separate the Date from the time in the data. Below is the data,
Step #1 – We do need to separate the contents of column A, but there is data in column B, so we need to insert another column between column A and column B. To do that, Select Column B and press CTRL + +.
It adds another column between both the columns and shifts the data from previous column B to column C.
Step #2 – Now select the data in Column A, and click on Text to the column under Data Tab in the Data Tools section.
A dialog box appears for text to columns wizard.
Step #3 – This time, we are using a fixed-width method, so make sure that the fixed method option is selected and click on next. Another Text to Column Wizard dialog box appears.
Step #4 – In the data preview, we can see that the data is being separated into three parts, which are Data Time and the meridian, which is AM and PM.
We need only data and time, so hover the mouse around the second line and double click on it, and it disappears.
Step #5 – Now click on next, another Text to Column Wizard dialog box appears. There you need to click on the Finish button.
Now, the data is separated with Date in one column and time in another.
Step #6 – Currently, the formatting of the data in column B is not correct, so we need to correct it. Select the contents on column B, and in the Home tab under the numbers section, the default selection is custom. We need to change it to time.
Step #7 – Now, we have successfully separated our excel data using the Text to Columns Fixed Width Method.
Example #3 – Using Formulas for Separating Text
We can also use excel formulas to separate the text and numbers, which is joined together. Of course, we can remove that data by using Text to columns, but for complex situations, we use formulas for this.
Let us consider the following Data:
We have products in column A with their respective product codes. We need products in one column and product code in another. We want to use formulas to do this.
Step #1- To this, we need to first count the number of digits and separate that much number from the character.
Step #2- We need Product Name in B Column and Product Code in the C column.
Step #3- First, we will separate the digits so that then we can separate the text in excel from the data. In C2, write the following excel formula to separate text.
We use the right to function as we know the numbers are in the right.
Step #4- Now, in Cell B2, write the following Formula,
Step #5- Press Enter, and we have successfully separated our data from Product Name and code by using the Len function.
Step #6- Now drag the respective formulas to cell B6 and cell C6 Respectively.
Things to Remember in Separating Text in Excel (text to column & formula)
- If we are using the Text to Columns Method, always make sure that we have an additional column so that the data in any column doesn’t get replaced.
- If we are separating Texts in excel by using excel formulas, we need to make sure of the positioning of the characters.
This has been a guide to Separate Text in Excel. Here we discuss how to separate text in excel using two methods 1) “Text to Column” (Delimited & Fixed Width) and 2) using Excel Formulas along with practical examples and a downloadable template. You may learn more about excel from the following articles –