+ Reply to Thread
Results 1 to 10 of 10

Extracting two words from a string

  1. #1
    Registered User
    Join Date
    04-14-2013
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    3

    Extracting two words from a string

    Hello,

    I was wondering if someone can assist.

    I have a string in the format:

    0000000000 Text Text Text, 2008 Text Text-Text-Text for FirstName LastName #000000

    I need a formula to extract the First Name and Last Name from the string to another column without any white spaces inbetween.

    So far, I have come up with: =REPLACE(A1,1,FIND("for",A1)+3,"") which gives me the following result: FirstName LastName #000000

    I need to get rid of the last bit, '#000000' and remove the white-space in-between FirstName and LastName.

    Thank you.

  2. #2
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,156

    Re: Extracting two words from a string

    hi HM001, welcome to the forum. try:
    =LEFT(MID(A1,FIND(" for ",A1)+5,255),FIND("#",MID(A1,FIND(" for ",A1)+5,255))-2)

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  3. #3
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Extracting two words from a string

    Try

    =TRIM(REPLACE(REPLACE(A1,FIND("#",A1),LEN(A1),""),1,FIND("for",A1)+3,""))

  4. #4
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Extracting two words from a string

    err, it's a bit claggy but it works

    =LEFT(LEFT(REPLACE(A1,1,FIND("for",A1)+3,""),FIND("#",REPLACE(A1,1,FIND("for",A1)+3,""),1)-2),FIND(" ",LEFT(REPLACE(A1,1,FIND("for",A1)+3,""),FIND("#",REPLACE(A1,1,FIND("for",A1)+3,""),1)-2),1)-1)&RIGHT(LEFT(REPLACE(A1,1,FIND("for",A1)+3,""),FIND("#",REPLACE(A1,1,FIND("for",A1)+3,""),1)-2),LEN(LEFT(REPLACE(A1,1,FIND("for",A1)+3,""),FIND("#",REPLACE(A1,1,FIND("for",A1)+3,""),1)-2))-FIND(" ",LEFT(REPLACE(A1,1,FIND("for",A1)+3,""),FIND("#",REPLACE(A1,1,FIND("for",A1)+3,""),1)-2),1))
    Elegant Simplicity............. Not Always

  5. #5
    Registered User
    Join Date
    04-14-2013
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Extracting two words from a string

    Thanks guys for the quick reply :D

    I can now get the FirstName and LastName.

    Is there a way to tweak it so there is no whitespace between FirstName and LastName?

  6. #6
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Extracting two words from a string

    Perhaps

    =SUBSTITUTE(REPLACE(REPLACE(A1,FIND("#",A1),LEN(A1),""),1,FIND("for",A1)+3,"")," ","")

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

    Re: Extracting two words from a string

    Hi HM001

    Another version:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    But I also see
    remove the white-space in-between FirstName and LastName
    Add another SUBSTITUTE function to the previous one.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Regards Kevin


    Merged Cells (They are the work of the devil!!!)

  8. #8
    Registered User
    Join Date
    04-14-2013
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Extracting two words from a string

    Yeay! Thank you very much everyone!

    Just was I was looking for.

    Saved me from loads of stress today.

  9. #9
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Extracting two words from a string

    Great, glad to help.

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

    Re: Extracting two words from a string

    Hi HM001

    No problem and thanks for the feed back.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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