+ Reply to Thread
Results 1 to 17 of 17

Way to extract the leftmost as well as rightmost characters until first encountered space

  1. #1
    Registered User
    Join Date
    11-06-2012
    Location
    Aalborg, Denmark
    MS-Off Ver
    Excel 2010
    Posts
    7

    Way to extract the leftmost as well as rightmost characters until first encountered space

    Hey there everyone!

    What i am trying to do is to separate some names, but this needs to work with a bunch of names, which are very different, some are only first names and last names, and some have up to three middle names. I will give some examples:

    Aksel Bertelsen
    Anders Bo Friesgaard Christensen
    Anita Lisa Georgia James Linde

    What i need to do is get the very first name and the very last name in two different cells, so the names would look like this

    A1 A2
    Aksel Bertelsen
    Anders Christensen
    Anita Linde

    Hope this is something you can help with!

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,078

    Re: Way to extract the leftmost as well as rightmost characters until first encountered sp

    For first name
    =LEFT(A1,FIND(" ",A1)-1)

    For last name
    =RIGHT(A1,LEN(A1)-FIND("*",SUBSTITUTE(A1," ","*",LEN(A1)-LEN(SUBSTITUTE(A1," ","")))))

    Sourcce: http://www.excelforum.com/excel-gene...-a-string.html
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Forum Contributor
    Join Date
    10-18-2012
    Location
    Telford, England
    MS-Off Ver
    Excel 2010 (2003)
    Posts
    294

    Re: Way to extract the leftmost as well as rightmost characters until first encountered sp

    where do the names start? I will assume col a, with col b and col c for the spilt (I know that's not what you said.

    for r = 1 to activesheet.usedrange.rows.count
    stemp = cells(r,1)
    cells(R,2) = left(stemp ,instr(stemp ," ")-1)
    cels(R,3 = mid(cells(R,instrrev(stemp ," ")+1)
    next

  4. #4
    Banned User!
    Join Date
    10-14-2006
    Posts
    1,211

    Re: Way to extract the leftmost as well as rightmost characters until first encountered sp

    First name:

    =LEFT(A1,FIND(" ",A1)-1)

    Last name:

    =TRIM(RIGHT(SUBSTITUTE(A1," ",REPT(" ",99)),99))

  5. #5
    Registered User
    Join Date
    11-06-2012
    Location
    Aalborg, Denmark
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Way to extract the leftmost as well as rightmost characters until first encountered sp

    Thank you for the answers

    Unfortunately the firstname function does not work, when i enter it, it just returns a blank cell.

    The last name function works most of the times, but it also returns a blank at some names, i will post some examples where it returns a blank cell:
    Annamaria G. Elena Giraldi
    Ann-Charlotte Jensen
    Anne A. Elgaard Thorup
    Anne Grethe Birch Pedersen

  6. #6
    Forum Expert Moo the Dog's Avatar
    Join Date
    09-28-2012
    Location
    Wisconsin
    MS-Off Ver
    Office 365 (PC & Mac)
    Posts
    1,845

    Re: Way to extract the leftmost as well as rightmost characters until first encountered sp

    All of the formulas proposed above work fine if your original name/string is in cell A1. Only way you would get blanks is if your original data is in another cell.

    - Moo

  7. #7
    Registered User
    Join Date
    11-06-2012
    Location
    Aalborg, Denmark
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Way to extract the leftmost as well as rightmost characters until first encountered sp

    My original data is in cell A1, then continuing to cell A2, A3 and so on.
    But there is an occasional blank cell along the rows

  8. #8
    Valued Forum Contributor
    Join Date
    10-29-2012
    Location
    Mojokerto,Indonesia
    MS-Off Ver
    Excel 2007
    Posts
    554

    Re: Way to extract the leftmost as well as rightmost characters until first encountered sp

    try it
    =TRIM(LEFT(SUBSTITUTE(A1," ",REPT(" ",100)),100)&" "&TRIM(RIGHT(SUBSTITUTE(A1," ",REPT(" ",100)),100)))

  9. #9
    Registered User
    Join Date
    11-06-2012
    Location
    Aalborg, Denmark
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Way to extract the leftmost as well as rightmost characters until first encountered sp

    Thank you Ghozi! That formula worked perfectly!

    Although i still get blanks from the formula for extracting the first name

  10. #10
    Forum Expert Kevin UK's Avatar
    Join Date
    12-07-2010
    Location
    Radstock, Somerset
    MS-Off Ver
    365
    Posts
    1,922

    Re: Way to extract the leftmost as well as rightmost characters until first encountered sp

    Hi

    How come Ghozi Alkatiri formula works! When in your original post:
    What i need to do is get the very first name and the very last name in two different cells, so the names would look like this

    A1 A2
    Aksel Bertelsen
    Anders Christensen
    Anita Linde

  11. #11
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Way to extract the leftmost as well as rightmost characters until first encountered sp

    Just out of interest, provided you need the First & Last Name in seperate cells.
    Combine the suggestion by teethless mamma
    In B1 Drag across to C1, then down
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  12. #12
    Registered User
    Join Date
    11-06-2012
    Location
    Aalborg, Denmark
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Way to extract the leftmost as well as rightmost characters until first encountered sp

    Kevin: It works to get the last name, which the other formulas didnt accomplish for some reason, i still havent got a formula which can isolate the first name

  13. #13
    Forum Expert Moo the Dog's Avatar
    Join Date
    09-28-2012
    Location
    Wisconsin
    MS-Off Ver
    Office 365 (PC & Mac)
    Posts
    1,845

    Re: Way to extract the leftmost as well as rightmost characters until first encountered sp

    Exasis,

    Perhaps it would help if you uploaded a copy of your file for people to assist with, instead of having us guess as to why it's not working - possibly due to formatting, irregular conditions, etc.

    - Moo

  14. #14
    Forum Expert Kevin UK's Avatar
    Join Date
    12-07-2010
    Location
    Radstock, Somerset
    MS-Off Ver
    365
    Posts
    1,922

    Re: Way to extract the leftmost as well as rightmost characters until first encountered sp

    Hi exasis

    Try assuming you data is in column A
    First name:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Last Name:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Or are the last names double barrel!

  15. #15
    Registered User
    Join Date
    11-06-2012
    Location
    Aalborg, Denmark
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Way to extract the leftmost as well as rightmost characters until first encountered sp

    Moo: I would love to if i was allowed, but i had trouble enough being allowed to even show some names, as it is connected to some very sensitive data

  16. #16
    Forum Expert Kevin UK's Avatar
    Join Date
    12-07-2010
    Location
    Radstock, Somerset
    MS-Off Ver
    365
    Posts
    1,922

    Re: Way to extract the leftmost as well as rightmost characters until first encountered sp

    See attached:

  17. #17
    Registered User
    Join Date
    11-06-2012
    Location
    Aalborg, Denmark
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Way to extract the leftmost as well as rightmost characters until first encountered sp

    Thank you Kevin! It worked after i changed the "-1" to "4" for some reason

+ 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