You will often receive spreadsheets with usernames. Sometimes these spreadsheets have the first name and the second name in different columns. However, spreadsheets usually contain the Full name in a single column. So what do you do then? Simply follow the options mentioned below to split the user name as first name and last name into two columns.
Get First Name And Last Name Through The GUI
Excel’s Convert Text To Column
Excel’s parsing concept helps you to split and spread text from one column to multiple columns. We can parse full name into first name and last name using Excel’s text to columns wizard. Follow the steps mentioned below to understand how Text to Columns works:
Step 1: Select the column that contains the full name. Instead of selecting an entire column, you can also select a range and not select text from multiple columns. Additionally, ensure that there are empty columns to the right of the selected range or column. This is an important step as text on adjacent columns will be overwritten if there are no empty columns.
Step 2: On your Excel ribbon, select Data and then click the option “Text to Columns.” You will now see the Convert Text to Columns Wizard.
Step 3: The first step in this wizard is to select the data type. You have two options. First is the Delimited and the second is Fixed Width. Select Delimited if your data is separated by characters such as commas, tabs, any other special characters or symbols. Select the option Fixed width if fixed-width spaces separate the data in your column.
Step 4: If you have chosen Delimited, you will choose the delimiters on the next screen. Available options are as follows;
1) Tab
2) Semicolon
3) Comma
4) Space
5) Other
If you select option 5, ‘Other,’ it would allow you to type a character in a text box.
If you have chosen the option Fixed Width rather than Delimiter, you will set Column Breaks. To insert Columns breaks in the data preview window, click on the desired position.
To delete a column break, double-click on it. To move a column break, you can click and drag it to the new position.
Step 5: The third screen would allow you to set the data type for the new column populated with the data created at the end of this wizard. The default option is General, which converts numeric values to numbers, date values to dates, and all remaining values to text.
Other available options are Text and Date. You also have an option that does not import the data to a column.
Step 6: Press Finish, and you will be able to see the First Name and the Last Name in new columns.
Get the First Name And Last Name Using Formulas
Level Of Difficulty: LOW
There are no direct and specific formulas in Excel to convert the Full name into first name and last name. However, by combining multiple excel formulas, we can achieve this.
To Get The First Name
Using LEFT and SEARCH formulas, you can build a formula to extract the first name. Below is the syntax;
Syntax:
To replace the CELL ADDRESS in the above syntax with the actual value as shown in the example below:
According to this example, the full name is present in Cell B2. When we type this formula in cell C2, it will generate the first name.
To Get The Last Name
Using RIGHT, LEN, SEARCH formulas, you can build a formula to extract the last name. Below is the syntax;
Syntax:
To replace the CELL ADDRESS in the above syntax with the actual value as shown in the example below:
According to this example, the full name is present in Cell B2. When we type this formula in Cell D2, it will generate the Last name.
How does it work?
The formula searches for space or comma in the cell’s text. If space or comma is found, all the text found on its left is extracted and displayed as the first name.
The last name is displayed by extracting all text to the right of the space or comma.
Get the First Name And Last Name Using Macro
Using a macro, you can create user-defined functions. You can then use these functions in your Excel sheets. This will help you attain your goal using a single function.
After posting these scripts into a new module, the cell containing the full name should be passed as the parameter to these user-defined functions.