+ Reply to Thread
Results 1 to 9 of 9

vlookup/index-match w/ multiple lookup values

  1. #1
    Registered User
    Join Date
    04-10-2015
    Location
    WA
    MS-Off Ver
    2010 & mac 2008
    Posts
    4

    vlookup/index-match w/ multiple lookup values

    Hi all -

    This is a gross simplification of a more complex issue, but I think if I can figure this part out, the rest should fall in line. (And I've spent WAY too much time trying to work it out myself and have stretched my minute knowledge to the limit )

    Here's a simplified table:

    First Last Data Last,First Data
    John Smith Smith, David ###
    xxx xxx Smith, John ###
    xxx xxx Jones, John ###

    The basic gist is that I'd like to use either VLOOKUP or INDEX-MATCH to find both the First AND Last name text strings (e.g., "John" AND "Smith") within the same cell of the Last,First column (e.g., "Smith, John") and return the adjacent value into the corresponding empty cell. With the commas and spaces, I know I need to search for partial matches, incorporate wildcards, etc., but I haven't been able to put it all together.

    Any help would be greatly appreciated.

    Thanks -

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: vlookup/index-match w/ multiple lookup values

    I would suggest including a helper column between B and C which contains the formula...

    =A2 & ", " & B2 (in row2 and copy down).

    You can then use this to look up the appropriate data.

    Or

    =VLOOKUP(A2&", "&B2,D:E,2,0) in C2
    Martin

  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: vlookup/index-match w/ multiple lookup values

    This would also work (IF I understand you cottectly)...
    A
    B
    C
    D
    E
    1
    First Last Data Last,First Data
    2
    John Smith Smith, David aa
    3
    xxx xxx Smith, John bb
    4
    xxx xxx Jones, John cc
    5
    6
    bb


    A6=INDEX($E$2:$E$4,MATCH(B2&", "&A2,$D$2:$D$4,0))
    and so would this...
    =VLOOKUP(B2&", "&A2,$D$2:$E$4,2,0)
    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
    04-10-2015
    Location
    WA
    MS-Off Ver
    2010 & mac 2008
    Posts
    4

    Re: vlookup/index-match w/ multiple lookup values

    Thank you, mrice and FDibbins.

    Both
    =INDEX($E$2:$E$4,MATCH(B2&", "&A2,$D$2:$D$4,0))
    and
    =VLOOKUP(B2&", "&A2,$D$2:$E$4,2,0)
    worked.

    Now, a quick follow-up to make things a tiny bit more complicated.

    Using the same table, say there were other text and numbers along with the name in the First,Last cells (e.g., "ABC Smith, John 2015").
    How could I then incorporate a search for the First,Last cell that contains both "John" AND "Smith" (so, two required partial strings and not an exact match) using VLOOKUP or INDEX-MATCH?

    I hope that's not too muddled.

  5. #5
    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: vlookup/index-match w/ multiple lookup values

    A
    B
    C
    D
    E
    1
    First Last Data Last,First Data
    2
    John Smith abc Smith, David 2015 aa
    3
    xxx xxx aaa Smith, John 2012 bb
    4
    xxx xxx bbbb Jones, John 1234 cc
    5
    6
    bb
    7
    bb

    A6=INDEX($E$2:$E$4,MATCH("*"&B2&", "&A2&"*",$D$2:$D$4,0))
    A7=VLOOKUP("*"&B2&", "&A2&"*",$D$2:$E$4,2,0)

    I just added a wild card (*) each side

  6. #6
    Registered User
    Join Date
    04-10-2015
    Location
    WA
    MS-Off Ver
    2010 & mac 2008
    Posts
    4

    Re: vlookup/index-match w/ multiple lookup values

    Got it. Awesome. Thank you so much.

    And if there was text between the two partials I'd just put a wildcard in between them:
    =INDEX($E$2:$E$4,MATCH("*"&B2&"*"&A2&"*",$D$2:$D$4,0))
    =VLOOKUP("*"&B2&"*"&A2&"*",$D$2:$E$4,2,0)

    Finally (and thank you for humoring me), what if I don't know which order they will appear in the Last,First cell (e.g., "abc John Smith 2015" or "2015 Smith, John abc")?

  7. #7
    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: vlookup/index-match w/ multiple lookup values

    By Gove, I think he has it! hehe well done

    For the "Finally", that gets a bit more tricky

    =INDEX($E$2:$E$4,IFERROR(MATCH("*"&B2&", "&A2&"*",$D$2:$D$4,0),MATCH("*"&A2&", "&B2&"*",$D$2:$D$4,0)))

    I added an error trap, and included the same MATCH function, but with the names in reverse order

  8. #8
    Registered User
    Join Date
    04-10-2015
    Location
    WA
    MS-Off Ver
    2010 & mac 2008
    Posts
    4

    Re: vlookup/index-match w/ multiple lookup values

    Thank you very much.

    For my purposes, I replaced ", " with "*", and it's working fine.

    I guess with all of this, I was conceptualizing the searching for multiple partial strings a bit differently with a bunch of half-learned coding languages floating around in my brain.

    Much obliged.

  9. #9
    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: vlookup/index-match w/ multiple lookup values

    Im happy we were able to get you where you needed to be

    If this answered your question, please take a moment to mark the thread as "solved" - it helps keep things neat and tidy lol, and consider adding the reputation to those that helped (see points 2 & 3 below my 1st post to you)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Returning multiple distinct/repeating values for vlookup or index-match
    By amatvien in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 08-21-2018, 01:14 PM
  2. INDEX/MATCH multiple lookup values
    By mythbit in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-07-2015, 08:55 AM
  3. Vlookup or Index Match to populate multiple values
    By HB07 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-30-2015, 05:18 AM
  4. [SOLVED] Lookup match index multiple values return other columns
    By martypocock in forum Excel Formulas & Functions
    Replies: 25
    Last Post: 11-07-2012, 10:57 PM
  5. [SOLVED] Formula (VLOOKUP vs INDEX & MATCH) to return multiple values in the same column
    By wfidler in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-06-2012, 07:04 PM

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