SOLVED
Home

Separate full name field into three separate columns.

%3CLINGO-SUB%20id%3D%22lingo-sub-1013973%22%20slang%3D%22en-US%22%3ESeparate%20full%20name%20field%20into%20three%20separate%20columns.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1013973%22%20slang%3D%22en-US%22%3E%3CP%3EI'm%20trying%20to%20separate%20the%20first%2Cmiddle%20and%20last%20names%20into%20separate%20columns.%20The%20problem%20I'm%20running%20into%20is%20that%20some%20full%20names%20contain%20a%20%22.%22%20with%20the%20middle%20initial%20and%20some%20do%20not%20and%20others%20simple%20have%20no%20middle%20initial%20at%20all.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20in%20advance%20for%20your%20time%20and%20consideration.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESample%20file%20attached.%3C%2FP%3E%3CP%3EMn%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1013973%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1013999%22%20slang%3D%22en-US%22%3ERe%3A%20Separate%20full%20name%20field%20into%20three%20separate%20columns.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1013999%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F460314%22%20target%3D%22_blank%22%3E%40mnelsonhd%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPerhaps%20the%20attached%20file%20will%20give%20achieve%20what%20you%20are%20after.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1014002%22%20slang%3D%22en-US%22%3ERe%3A%20Separate%20full%20name%20field%20into%20three%20separate%20columns.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1014002%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F460314%22%20target%3D%22_blank%22%3E%40mnelsonhd%3C%2FA%3E%26nbsp%3BHi.%20Looks%20like%20you%20have%20some%20which%20contain%20a%20middle%20initial%20and%20some%20which%20don't.%20The%20way%20I'd%20handle%20this%20is%20to%20process%20the%20name%20separating%20the%20parts%20by%20using%20the%20spaces%20as%20a%20separator.%20Where%20the%20name%20is%20in%20three%20parts%20(containing%20a%20middle%20initial)%2C%20process%20one%20way%2C%20and%20for%20those%20without%2C%20process%20a%20different%20way.%20If%20all%20of%20the%20names%20are%20in%20the%20first%20column%20of%20the%20sheet%20and%20there%20are%20no%20empty%20rows%20in%20the%20middle%2C%20something%20like%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFunction%20SplitName()%3C%2FP%3E%3CP%3EDim%20names()%20As%20String%3C%2FP%3E%3CP%3EFor%20i%20%3D%201%20To%20Rows.Count%3CBR%20%2F%3E%3CBR%20%2F%3EIf%20Cells(i%2C%201).Value%20%3D%20%22%22%20Then%3CBR%20%2F%3E'%20No%20more%20data%20to%20process%3CBR%20%2F%3EExit%20Function%3CBR%20%2F%3EElse%3CBR%20%2F%3E'%20Process%20the%20cell%3CBR%20%2F%3Enames%20%3D%20Split(Cells(i%2C%201).Value)%3CBR%20%2F%3E'%20If%20it's%20two%20names%2C%20put%20into%20first%20and%20last%20name%3CBR%20%2F%3EIf%20UBound(names())%20%3D%201%20Then%3CBR%20%2F%3ECells(i%2C%203).Value%20%3D%20names(0)%3CBR%20%2F%3ECells(i%2C%205).Value%20%3D%20names(1)%3CBR%20%2F%3EElse%3CBR%20%2F%3E'%20Otherwise%2C%20put%20the%20middle%20initial%20or%20name%20into%20the%20middle%20cell%3CBR%20%2F%3ECells(i%2C%203).Value%20%3D%20names(0)%3CBR%20%2F%3ECells(i%2C%204).Value%20%3D%20names(1)%3CBR%20%2F%3ECells(i%2C%205).Value%20%3D%20names(2)%3CBR%20%2F%3EEnd%20If%3CBR%20%2F%3E%3CBR%20%2F%3EEnd%20If%3C%2FP%3E%3CP%3ENext%20i%3C%2FP%3E%3CP%3EEnd%20Function%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1014050%22%20slang%3D%22en-US%22%3ERe%3A%20Separate%20full%20name%20field%20into%20three%20separate%20columns.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1014050%22%20slang%3D%22en-US%22%3EHello%2C%3CBR%20%2F%3E%3CBR%20%2F%3EYou%20can%20use%20the%20Flash%20Fill%20to%20extract%20(separate)%20and%20join%20(combine)%20first%2C%20middle%20and%20last%20name%3CBR%20%2F%3E%3CBR%20%2F%3EExample%3A%3CBR%20%2F%3EAssume%20you%20have%20Full%20Name%20in%20column%20A1%20such%20as%20Abiola%20David%20Smith%20where%20Abiola%20is%20the%20First%20Name%2C%20David%20is%20the%20Middle%20Name%20and%20Smith%20is%20the%20Last%20Name%3CBR%20%2F%3EIn%20column%20B%2C%20type%20is%20Abiola%20and%20click%20Enter.%20Then%20execute%20CTRL%20%2B%20E.%20All%20the%20First%20Name%20in%20column%20A%20will%20be%20extracted.%20Then%20you%20can%20do%20the%20same%20for%20Middle%20Name%20and%20Last%20Name.%20So%20easy%3CBR%20%2F%3E%3CBR%20%2F%3EOn%20the%20other%20hand%2C%20you%20can%20use%20LEFT%2C%20MID%2FFIND%20and%20RIGHT%20functions%20to%20extract%20values.%3CBR%20%2F%3E%3CBR%20%2F%3ERegards%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1014076%22%20slang%3D%22en-US%22%3ERe%3A%20Separate%20full%20name%20field%20into%20three%20separate%20columns.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1014076%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F421698%22%20target%3D%22_blank%22%3E%40Abiola1%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20for%20the%20help.%20Unfortunately%20the%20solution%20provided%20wasn't%20able%20to%20completely%20work%20without%20errors.%20I've%20tried%20several%20times%20but%20for%20whatever%20reason%20it%20will%20randomly%20add%20a%20letter%20here%20and%20there.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
mnelsonhd
New Contributor

I'm trying to separate the first,middle and last names into separate columns. The problem I'm running into is that some full names contain a "." with the middle initial and some do not and others simple have no middle initial at all.

 

Thank you in advance for your time and consideration.

 

Sample file attached.

Mn

7 Replies
Solution

@mnelsonhd 

Perhaps the attached file will achieve what you are after.

 

@mnelsonhd Hi. Looks like you have some which contain a middle initial and some which don't. The way I'd handle this is to process the name separating the parts by using the spaces as a separator. Where the name is in three parts (containing a middle initial), process one way, and for those without, process a different way. If all of the names are in the first column of the sheet and there are no empty rows in the middle, something like:

 

Function SplitName()

Dim names() As String

For i = 1 To Rows.Count

If Cells(i, 1).Value = "" Then
' No more data to process
Exit Function
Else
' Process the cell
names = Split(Cells(i, 1).Value)
' If it's two names, put into first and last name
If UBound(names()) = 1 Then
Cells(i, 3).Value = names(0)
Cells(i, 5).Value = names(1)
Else
' Otherwise, put the middle initial or name into the middle cell
Cells(i, 3).Value = names(0)
Cells(i, 4).Value = names(1)
Cells(i, 5).Value = names(2)
End If

End If

Next i

End Function

@Riny_van_Eekelen 

WOW! works like a champ. Now that the name has been solved I have one last issue..... in the office/company field some company names also contain the contact phone number in the same field vs the phone column. Lastly the email column contains an "A" after the email address making them impossible to use.

Again, Thank you in advance as you've saved countless hours searching the internet and making corrections to over 2k of names!!!

 

New file attached.

 

Hello,

You can use the Flash Fill to extract (separate) and join (combine) first, middle and last name

Example:
Assume you have Full Name in column A1 such as Abiola David Smith where Abiola is the First Name, David is the Middle Name and Smith is the Last Name
In column B, type is Abiola and click Enter. Then execute CTRL + E. All the First Name in column A will be extracted. Then you can do the same for Middle Name and Last Name. So easy

On the other hand, you can use LEFT, MID/FIND and RIGHT functions to extract values.

Regards

@Abiola1 

Thank you for the help. Unfortunately the solution provided wasn't able to completely work without errors. I've tried several times but for whatever reason it will randomly add a letter here and there.

@mnelsonhdthe formula in the attachment may help. you may use the number of spaces in a cell as an indicator of the number of words.

@mnelsonhd 

Rather than creating one huge formula to do the job, I prefer to break the problem into smaller pieces.

Your data for Name, Phone and E-mail is indeed quite dirty and not consistent. The only consistency I find in your example is that phone numbers are always 12 characters long (10 digits plus 2 separators).

The email adress always seems to be in its own column, so I'll deal with that separately.

 

The attached workbook describes the four steps needed to clean-up the data.

Step 1: Get your original data (highlighted yellow)

Step 2: TEXTJOIN the first two columns

Step 3: Split Name and Phone# using LEFT, RIGHT and LEN

Step 4: Get rid of the " A" in the e-mail addresses and get rid of trailing spaces

 

A last step you may want to perform yourself is to do replace the "." in the phone numbers by "-". 

 

Now, I assume that this is not a process you will have to go through on a daily basis. If it is, you may need find a more automated solution.

Related Conversations
Tabs and Dark Mode
cjc2112 in Discussions on
46 Replies
Extentions Synchronization
Deleted in Discussions on
3 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
30 Replies
flashing a white screen while open new tab
Deleted in Discussions on
14 Replies
Security Community Webinars
Valon_Kolica in Security, Privacy & Compliance on
13 Replies