+ Reply to Thread
Results 1 to 6 of 6

LOOKUP using only part of a string?

  1. #1
    Registered User
    Join Date
    10-24-2012
    Location
    NZ
    MS-Off Ver
    Excel 2010
    Posts
    13

    LOOKUP using only part of a string?

    Is it possible to use one of the LOOKUP functions using only part of a string (rather than a cell's full content) as the lookup_value?

    I have a column of cells each containing a six-digit number. Each pair of digits within this number represents data stored elsewhere. I'd like to have my formula read the first two digits and return the matching data from the lookup_vector. I'd like another formula to read the second two digits and return the matching data from a different lookup_vector.

    It doesn't seem possible to use use a LOOKUP argument that searches the lookup_value as a string in order to use only part of that string as the criterion.

    I suspect there's a clever combination of suitable functions to achieve this, but I haven't managed to figure them out -- any suggestions will be most welcome.
    Last edited by KiwiLad; 11-19-2012 at 04:59 AM.
    Greg
    Excel 2010 on Win7Prof

  2. #2
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,361

    Re: LOOKUP using only part of a string?

    you could post a sample workbook.
    I think people forget the word "THANK YOU!!!!" Do you still know it???

    There is a little star ( ADD REPUTATION ) below those person who helped you. Click it to say your "PRIVATE APPRECIATION TO THEIR EFFORT ON THEIR CONTRIBUTIONS "

    Regards,
    Vladimir

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,933

    Re: LOOKUP using only part of a string?

    without seeing you're data, try this, assuming what you are looking for is in A1...
    =VLOOKUP(VALUE(LEFT(A1,2)),D8:E10,2,FALSE) for the 1st 2 numbers
    =VLOOKUP(VALUE(MID(A1,3,2)),D8:E10,2,FALSE) for the middle 2 numbers
    =VLOOKUP(VALUE(RIGHT(A1,2)),D8:E10,2,FALSE) for the last 2 numbers

    I assumed the data you are searching in wads in the range D8:E8 - adjust as needed
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  4. #4
    Registered User
    Join Date
    10-24-2012
    Location
    NZ
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: LOOKUP using only part of a string?

    Yes, I thought of doing so (and will), but that brings me to the second part of the challenge. The data in the lookup_vector is not simply the two-digit number contained within the lookup_value. It too is a longer string -- so I will need to specify both the part of the string to be used in the lookup_value and the part of the string in the look_up vector to be matched to the lookup_value. Confused?

    I hope the attached will make it clear.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    10-24-2012
    Location
    NZ
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: LOOKUP using only part of a string?

    Excellent! All I have to do now is apply the same LEFT-MID-RIGHT to the lookup_vector to achieve the desired match.

  6. #6
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,361

    Re: LOOKUP using only part of a string?

    you could also try index/match , something like this.

    =INDEX('2'!$C$3:$C$53,MATCH("*"&LEFT(H8,2)&"*",'2'!$B$3:$B$53,0))

+ 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