+ Reply to Thread
Results 1 to 4 of 4

Search/extract text

Hybrid View

  1. #1
    Registered User
    Join Date
    09-20-2005
    Location
    Atlanta, Georgia
    MS-Off Ver
    Office365
    Posts
    53

    Search/extract text

    Hello..

    I'm trying to figure out a better way to extract specific text from a text string. Right now I have 2 steps. I would like to have only 1 step..

    For example:

    A1 C:\Elandata\DataSet\121911B\QC1

    B1 =MID(A1,21,7) => this gives me 121911B

    Now I want to search the 121911B to see if the letter is A, B, C or D. I'm using:

    =IF(COUNT(SEARCH("A",B1)),"A",IF(COUNT(SEARCH("B",B1)),"B",IF(COUNT(SEARCH("C",B1)),"C",IF(COUNT(SEARCH("D",B1)),"D",""))))
    This will give a result of just A B C D. In this case it will give me a "B"

    Now the 121911B will change depending on the date and cycle. ie. could be 011311A or 011712D.. etc.

    Is there a way to do this in 1 step?

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

    Re: Is there a better way to search/extract text...

    Assuming there are always four seperators of "\" in the string and the character you are looking for is just before the fourth "\" try this

    =MID(A1,SEARCH(CHAR(127),SUBSTITUTE(A1,"\",CHAR(127),4))-1,1)
    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
    Registered User
    Join Date
    09-20-2005
    Location
    Atlanta, Georgia
    MS-Off Ver
    Office365
    Posts
    53

    Re: Is there a better way to search/extract text...

    Quote Originally Posted by Special-K View Post
    Assuming there are always four seperators of "\" in the string and the character you are looking for is just before the fourth "\" try this

    =MID(A1,SEARCH(CHAR(127),SUBSTITUTE(A1,"\",CHAR(127),4))-1,1)

    That worked great.. Thanks you!!!

  4. #4
    Forum Contributor ianh's Avatar
    Join Date
    11-19-2010
    Location
    Newcastle
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: Is there a better way to search/extract text...

    =right(mid(a1,21,7),1)
    2+2=5 for extremely large values of 2.

+ 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