+ Reply to Thread
Results 1 to 13 of 13

retrieving one word

Hybrid View

  1. #1
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Try:

    =MID(A1,SEARCH(B1,A1),SEARCH(" ",MID(A1&" ",SEARCH(B1,A1),255)))

    Where A1 contains original string and B1 contains string to search for.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  2. #2
    Registered User
    Join Date
    04-29-2006
    Posts
    68
    Quote Originally Posted by NBVC View Post
    Try:

    =MID(A1,SEARCH(B1,A1),SEARCH(" ",MID(A1&" ",SEARCH(B1,A1),255)))

    Where A1 contains original string and B1 contains string to search for.
    Thanks NBVC
    It is working with the word in the beginning of the sentence, but what about the word in the end of sentence??

  3. #3
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    It should also work with word at end of sentence...

    I tested it with your example#2 and got the expected result.

    Have you tried it? What error do you get?

  4. #4
    Forum Expert oldchippy's Avatar
    Join Date
    02-14-2005
    Location
    Worcester, UK
    MS-Off Ver
    Excel 2007 (Home)
    Posts
    7,097
    Hi,

    Just adding to NBVC example and looking at your very first example where its enclosed in brackets, you may need something like this

    =IF(RIGHT(MID(A1,SEARCH(B1,A1),SEARCH(" ",MID(A1&" ",SEARCH(B1,A1),255))),2)=") ",LEFT(MID(A1,SEARCH(B1,A1),SEARCH(" ",MID(A1&" ",SEARCH(B1,A1),255))),LEN(MID(A1,SEARCH(B1,A1),SEARCH(" ",MID(A1&" ",SEARCH(B1,A1),255))))-2))
    oldchippy
    -------------


    Blessed are those who can give without remembering and take without forgetting

    If you are happy with the help you have received, please click the <--- STAR icon on the left - Thanks.

    Click here >>> Top Excel links for beginners to Experts

    Forum Rules >>>Please don't forget to read these

  5. #5
    Registered User
    Join Date
    04-29-2006
    Posts
    68
    Quote Originally Posted by oldchippy View Post
    Hi,

    Just adding to NBVC example and looking at your very first example where its enclosed in brackets, you may need something like this

    =IF(RIGHT(MID(A1,SEARCH(B1,A1),SEARCH(" ",MID(A1&" ",SEARCH(B1,A1),255))),2)=") ",LEFT(MID(A1,SEARCH(B1,A1),SEARCH(" ",MID(A1&" ",SEARCH(B1,A1),255))),LEN(MID(A1,SEARCH(B1,A1),SEARCH(" ",MID(A1&" ",SEARCH(B1,A1),255))))-2))

    Thanks a lot

  6. #6
    Forum Expert oldchippy's Avatar
    Join Date
    02-14-2005
    Location
    Worcester, UK
    MS-Off Ver
    Excel 2007 (Home)
    Posts
    7,097
    Sorry error in my last formula, but this will work with both brackets and non-brackets

    =IF(RIGHT(MID(A2,SEARCH(B2,A2),SEARCH(" ",MID(A2&" ",SEARCH(B2,A2),255))),2)=") ",MID(A2,SEARCH(B2,A2),SEARCH(" ",MID(A2&" ",SEARCH(B2,A2),255))-2),MID(A2,SEARCH(B2,A2),SEARCH(" ",MID(A2&" ",SEARCH(B2,A2),255))))

  7. #7
    Registered User
    Join Date
    04-29-2006
    Posts
    68
    Quote Originally Posted by NBVC View Post
    It should also work with word at end of sentence...

    I tested it with your example#2 and got the expected result.

    Have you tried it? What error do you get?
    Dear NBVC,
    sorry for confusing you
    It is working for both examples

    Thaaaaaaaaaaaaaanks

+ 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