+ Reply to Thread
Results 1 to 4 of 4

splitting first, last, middle initial in separate columns

Hybrid View

  1. #1
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: splitting first, last, middle initial in separate columns

    If we assume strings are in A1:An then based on the samples:

    B1:
    =LEFT(A1,FIND(",",A1)-1)
    copied down
    
    C1:
    =REPLACE(LEFT(A1,FIND(" ",A1)-1),1,LEN(B1)+1,"")&IF(OR(RIGHT(A1)="&",ISERR(FIND("&",A1))),""," & "&TRIM(LEFT(SUBSTITUTE(REPLACE(A1,1,FIND("&",A1)+1,"")," ",REPT(" ",LEN(A1))),LEN(A1))))
    copied down
    
    D1:
    =TRIM(IF(AND(ISNUMBER(FIND("&",A1)),RIGHT(A1)<>"&"),IF(LEN(REPLACE(A1,1,FIND("& ",A1&"& ")+1,""))-LEN(SUBSTITUTE(REPLACE(A1,1,FIND("& ",A1&"& ")+1,"")," ","")),RIGHT(SUBSTITUTE(REPLACE(A1,1,FIND("&",A1)+1,"")," ",REPT(" ",LEN(A1))),LEN(A1)),""),SUBSTITUTE(LEFT(A1,FIND("&",A1&"&")-1),LEFT(A1,FIND(" ",A1)-1),"")))
    copied down
    The above would return:

    CAGLE | DANNY | D
    SNEIR | LARRY
    ALONSO | MERRIL | M
    KIM | JIN | SOO
    HARRISON | GEORGE & NANCY
    LUKS | BARBARA | VACCARO
    MILES | JAMIE & MARLON | D
    LITT | JEFFREY & LISA | J
    note per your requirements where multiple names and multiple middle name/initials only the right most is used


    Goes without saying that with more thought the above can be shortened significantly ... that said a UDF might still be preferable.
    Last edited by DonkeyOte; 10-12-2010 at 05:13 AM. Reason: duplicate formula posted by accident...

  2. #2
    Forum Contributor
    Join Date
    09-19-2010
    Location
    Philadelphia, PA
    MS-Off Ver
    Excel 2007
    Posts
    140

    Re: splitting first, last, middle initial in separate columns

    Thanks for replies.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1