+ Reply to Thread
Results 1 to 5 of 5

Excel 2007 : Extracting data from a string in a cell

Hybrid View

  1. #1
    Registered User
    Join Date
    11-25-2009
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    30

    Extracting data from a string in a cell

    I am trying to extract contract codes from a the string in the “SERVICE_CODES” column which contains numbers, punctuations and letters. I would like to return the data in the “Years” column of the service code table when the ct svc cde is found.
    I have tried the following functions below with no luck. Can anyone assist me?
    Thanks.

    SERVICE_CODES
    .T +( +/ *~ ;! ;= ;~ -~ >+ >? #B
    *O #D ATC05 HSC07 HSC42 PM WQ 5
    /H /K /0 /8 #C 5(
    #D HSC42 WQ
    #E HSC42 WQ

    Ct Svc CdeYears Months
    # B MTM MTM
    # C 1 YR 12 Months
    # D 2 YR 24 Months
    # E 3 YR 36 Months

    =LOOKUP(A2, {#B, #C, #D, #E}, {"MTM", "1Yr", "2Yr", "3Yr"}) – No luck

    =--(ISNUMBER(SEARCH("#B",A3))) – No luck

    =MID(A5,1,MIN(FIND({"#B","#C","#D","#E"},A1&"#B#C#D#E"))-1) – No luck

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Extracting data from a string in a cell

    I think I've got something you can use...
    With
    Your posted data in A1:A6
    and
    your lookup list in E1:G5
    Svc_Cde   Years    Months
    #B        MTM      MTM
    #C        1 YR     12_Months
    #D        2 YR     24_Months
    #E        3 YR     36_Months


    This regular formula returns the Years for cell A2
    B2: =INDEX($F$2:$F$5,MATCH(1,INDEX(COUNTIF($A2,"*"&$E$2:$E$5&"*"),0),0))


    This regular formula returns the Months for cell A2
    C2: =INDEX($G$2:$G$5,MATCH(1,INDEX(COUNTIF($A2,"*"&$E$2:$E$5&"*"),0),0))


    Copy those formulas down through Row_6

    With the test data, these are the results of those formulas
     
    MTM      MTM
    2 YR      24_Months
    1 YR      12_Months
    2 YR      24_Months
    3 YR      36_Months


    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Registered User
    Join Date
    04-11-2011
    Location
    Texas
    MS-Off Ver
    Office 2007
    Posts
    78

    Re: Extracting data from a string in a cell

    Quote Originally Posted by Ron Coderre View Post
    I think I've got something you can use...
    With
    Your posted data in A1:A6
    ...
    I'm not sure if that's what nickelcell was looking for but it's exactly what I needed. I was running into a similar issue of extracting data and Left(), Match(), and Find() weren't doing it for me but that use of Index works beautifully.

    A tip of the hat, and scale, to you sir.

  4. #4
    Registered User
    Join Date
    11-25-2009
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: Extracting data from a string in a cell

    Yes. It worked beautifully for me too.


    Thank you.

  5. #5
    Registered User
    Join Date
    11-25-2009
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: Extracting data from a string in a cell

    Sorry Ron. Just got back from vacation. I will test this and get back to you to let you know if this works for me. Thanks for your patience.

+ 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