I have a report that I need to be able to do a name split on. The data is not consistent.
- It will contain salutation (could be Mrs. or Mrs. or Mr. and Mrs. or Dr. and Mrs. or Dr. and Dr. etc)
- The name part can either be:
-- First name + last name
-- First name + middle name (or initial) + last name
-- first name + 2 middle names + last name
I need a way to split this off...
I do not need the salutations at all. So I found it easiest to highlight the column, do a control-F and choose replace. Then replace Mr. and all that with nothing. That solves that problem.
For the last name I use the following formula:
=RIGHT(E2, LEN(E2) - SEARCH("#", SUBSTITUTE(E2," ", "#", LEN(E2) - LEN(SUBSTITUTE(E2, " ", "")))))
For the first name only or first name and middle name I use:
=LEFT(E2, SEARCH(" ", E2) - 1)&" "&IFERROR(MID(E2,SEARCH(" ",E2,1)+1,SEARCH(" ",E2,SEARCH(" ",E2,1)+1)-SEARCH(" ",E2,1)),"")
Everything works perfectly except when there is a 2nd middle name. That simply gets removed and won't be included.
What formula could I use that would include the 2nd middle name? I was thinking of a formula that would include everything except the last name. So if there are 2 or 3 or 4 middle names, they would all be included. The formulas above i got from searching the net for help, but I have not been able to figure out the multiple middle name problem.
Thanks,
Michael
- It will contain salutation (could be Mrs. or Mrs. or Mr. and Mrs. or Dr. and Mrs. or Dr. and Dr. etc)
- The name part can either be:
-- First name + last name
-- First name + middle name (or initial) + last name
-- first name + 2 middle names + last name
I need a way to split this off...
I do not need the salutations at all. So I found it easiest to highlight the column, do a control-F and choose replace. Then replace Mr. and all that with nothing. That solves that problem.
For the last name I use the following formula:
=RIGHT(E2, LEN(E2) - SEARCH("#", SUBSTITUTE(E2," ", "#", LEN(E2) - LEN(SUBSTITUTE(E2, " ", "")))))
For the first name only or first name and middle name I use:
=LEFT(E2, SEARCH(" ", E2) - 1)&" "&IFERROR(MID(E2,SEARCH(" ",E2,1)+1,SEARCH(" ",E2,SEARCH(" ",E2,1)+1)-SEARCH(" ",E2,1)),"")
Everything works perfectly except when there is a 2nd middle name. That simply gets removed and won't be included.
What formula could I use that would include the 2nd middle name? I was thinking of a formula that would include everything except the last name. So if there are 2 or 3 or 4 middle names, they would all be included. The formulas above i got from searching the net for help, but I have not been able to figure out the multiple middle name problem.
Thanks,
Michael