
Tips.Net > ExcelTips Home > Formulas > Separating Names into Individual Columns
Summary: You can use the Text to Columns wizard to separate names into different cells. The success you have with this, however, depends on the condition of the original names: You may end up with names in two or three columns. The formulas in this tip are great for figuring out what part of a name goes into which column so that you have a better chance of consistent data after separation. (This tip works with Microsoft Excel 97, Excel 2000, Excel 2002, and Excel 2003.)
Lance has a set of names in a workbook. The names are all in column A, and some have first and last name, while others use first, middle and last names. He needs to separate the names into individual columns, but the Text to Columns wizard doesn't provide satisfactory results. It does the separation OK, but the two-vs.-three names issue means that Lance need to do a lot of manual massaging of the data once it is split up.
The solution to the problem is to not rely on the Text to Columns wizard, but instead use a number of formulas to get the names into columns. The results you achieve still depend, in large part, on the condition of the data you are parsing. If your data is in the format "first middle last" (with the middle name being optional), then you can use the following formula to pull out the first name:
=LEFT(A1,SEARCH(" ",A1,1)-1)
This formula checks for the first space in the name, and then assumes that everything before that space is the first name. The next formula is used to determine if there is a middle name, and if there is, display it:
=IF(ISERROR(SEARCH(" ",RIGHT(A1,LEN(A1)-SEARCH(" ",A1,1)),1))=TRUE,"",LEFT(RIGHT(A1,LEN(A1)-SEARCH(" ",A1,1)),SEARCH(" ",RIGHT(A1,LEN(A1)-SEARCH(" ",A1,1)),1)-1))
The formula checks for the existence of a second space in the name. If an error is generated (there is no second space) then the formula returns nothing; there is no middle name. If a second space is detected (there is no error generated), then the formula returns everything from after the first space up through the second space.
=RIGHT(A1,LEN(A1)-LEN(B1)-LEN(C1)-IF(C1="",1,2))
This formula relies on the results that were returned for both the first and middle names. It returns everything left in the original name after accounting for the length of the first name (assumed in cell B1) and the middle name (assumed in C1).
Again, these formulas work if the original data is in the "first last" or "first middle last" format. If there are qualifiers in the name such as Ms., Dr., Jr., or III, then you won't get satisfactory results. In addition, if the last name contains a space (as in "John van Kamp" or "Mary Anne St. Marie"), then you also won't get satisfactory results.
Tip #2789 applies to Microsoft Excel versions: 97 2000 2002 2003
Step Up and Take Control! Subscribers to ExcelTips know just how valuable a resource it is. ExcelTips Premium provides twice the number of exceptional, easy-to-understand tips every week in an ad-free newsletter, as well as substantial discounts on ExcelTips archives and e-books.
Check out ExcelTips Premium today!
Have thousands of ExcelTips at your fingertips, on your own system. Answer your own questions or help support others. (more information...)
Ask an Excel Question
Make a Comment
ExcelTips FAQ
ExcelTips Premium
Bugs and Pests Tips
ExcelTips
Family Tips
Health Tips
Home Tips
Organizing Tips
WordTips
Advertise on the
ExcelTips Site