+ Reply to Thread
Results 1 to 6 of 6

Extracting a word to the left of an opening bracket

  1. #1
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Extracting a word to the left of an opening bracket

    I have strings that contain variable text, but always contains a set of brackets:

    Today is the day that Andy Murray (a native of Scotland) plays tennis

    or

    Sometimes I get thirsty and (when that happens) I reach for a beer


    What I want to do is use the text formulae (no good at VBA!!) to extract
    "Andy" from the first string, and
    "and" from the second string

    i.e. the first word before the "(", symbol. I can nearly get it to work, but not quite... It's doing my nut in... Help!!!
    Last edited by Glenn Kennedy; 07-08-2012 at 11:59 AM.

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Extracting a word to the left of an opening bracket

    dont you mean Murray?
    =TRIM(MID(SUBSTITUTE(SUBSTITUTE(A1," (","^")," ",REPT(" ",50)),FIND("^",SUBSTITUTE(SUBSTITUTE(A1," (","^")," ",REPT(" ",50)))-30,30))
    Last edited by martindwilson; 07-08-2012 at 05:27 AM.
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Extracting a word to the left of an opening bracket

    Oh Cr@p. See what I mean about doing my nut in. Of course I mean Murray...

  4. #4
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Extracting a word to the left of an opening bracket

    Shorter and works better
    =trim(right(substitute(trim(left(a1,find("(",a1)-1))," ",rept(" ",50)),30))

  5. #5
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Extracting a word to the left of an opening bracket

    Quote Originally Posted by martindwilson View Post
    Shorter and works better
    =trim(right(substitute(trim(left(a1,find("(",a1)-1))," ",rept(" ",50)),30))

    Fantastic!! all I have to do is figure out why it works...

    Muchas gracias.

  6. #6
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Extracting a word to the left of an opening bracket

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

+ 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