+ Reply to Thread
Results 1 to 12 of 12

Vlookup with multiple matches

  1. #1
    Registered User
    Join Date
    04-29-2013
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    5

    Vlookup with multiple matches

    I have a spreadsheet where I need to match to another spreadsheet based off of two columns. Can I do a vlookup to match 2 columns and bring back the value of the 3rd? There will be multiples, but only one that will match both exactly. Like product numbers listed more than once and invoices more than once but there will only be one instance where they both match my other sheet and I would need to bring back the GL code on that.

  2. #2
    Registered User
    Join Date
    04-04-2013
    Location
    San Francisco, California
    MS-Off Ver
    Excel 2010
    Posts
    69

    Re: Vlookup with multiple matches

    You can't use VLOOKUP like that but you can use a different formula, e.g. to find the first row where the criteria is met in columns A, B and C and then return the value from D

    FYI its an array

    =INDEX(D1:D100,MATCH(1,(A1:A100="x")*(B1:B100="y")*(C1:C100="z"),0))

    confirmed with CTRL+SHIFT+ENTER

  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,946

    Re: Vlookup with multiple matches

    Hi and welcome to the forum

    An alternative to the array offered above would be to add a helper column and combine the other 2 cells/columns. This can be hidden, and if you add it to the left of your data, you can still use the standard vlookup(). If you add the helper column to the right of the data, you will need to use an index/match formula.

    If you upload a sample workbook, I can show you how to do this.

    Array formulas are fine, but can start to slow files down if you have a LOT of data that they are working on
    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-04-2013
    Location
    San Francisco, California
    MS-Off Ver
    Excel 2010
    Posts
    69

    Re: Vlookup with multiple matches

    Good idea! you can have the helper column be a concatenate of the two columns so you could use a single V-Lookup to locate the value.

  5. #5
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Vlookup with multiple matches

    normally entered
    =index(D1:D100,match("x"&"y"&"z",index(A1:A100&B1:B100&C1:C100,0),0))
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  6. #6
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    Office 2021
    Posts
    2,237

    Re: Vlookup with multiple matches

    If your output column is always be after the ONE of the condition, you could use VLOOKUP as array formula.


    A
    B
    C
    D
    E
    F
    1
    Head 1
    Head 2
    Head 3
    Head 1:
    1
    2
    1
    100
    1
    Head 3:
    5
    3
    2
    110
    2
    4
    3
    120
    3
    Result:
    140
    5
    4
    130
    4
    6
    1
    140
    5
    7
    6
    150
    6
    8
    7
    160
    7
    9
    8
    170
    8
    10
    1
    180
    9


    Array Formula in F4,

    =VLOOKUP(F1,IF(C2:C10=F2,A2:B10),2,0)
    Regards,
    Haseeb Avarakkan

    __________________________________
    "Feedback is the breakfast of champions"

  7. #7
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Vlookup with multiple matches

    Something like this...

    Data Range
    A
    B
    C
    D
    E
    F
    G
    1
    Region
    Level
    Manager
    -----
    Region
    Level
    Manager
    2
    North
    1
    Smith
    South
    2
    Keller
    3
    East
    1
    Jones
    4
    South
    1
    James
    5
    West
    1
    Little
    6
    North
    2
    Richards
    7
    East
    2
    Brown
    8
    South
    2
    Keller
    9
    West
    2
    Bifferson


    This array formula** entered in G2:

    =INDEX(C$2:C$9,MATCH(F2,IF(A$2:A$9=E2,B$2:B$9),0))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  8. #8
    Banned User!
    Join Date
    10-14-2006
    Posts
    1,211

    Re: Vlookup with multiple matches

    Another one....

    Based on Tony Valko table listed the above


    G2: =LOOKUP(2,1/(A2:A9=E2)/(B2:B9=F2),C2:C9)


    Normally Enter

  9. #9
    Registered User
    Join Date
    04-29-2013
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Vlookup with multiple matches

    sample.xls

    Thanks for all the answers, here is a quick scaled down sample of what I will need to be able to do. I will have to fill in the GL code on a second spreadsheet based on the Tracking Number & Invoice. There will be a lot of data in the real file.


    Quote Originally Posted by FDibbins View Post
    Hi and welcome to the forum

    An alternative to the array offered above would be to add a helper column and combine the other 2 cells/columns. This can be hidden, and if you add it to the left of your data, you can still use the standard vlookup(). If you add the helper column to the right of the data, you will need to use an index/match formula.

    If you upload a sample workbook, I can show you how to do this.

    Array formulas are fine, but can start to slow files down if you have a LOT of data that they are working on

  10. #10
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Vlookup with multiple matches

    Enter this array formula** in H2 and copy down:

    =INDEX(C$2:C$9,MATCH(G2,IF(A$2:A$9=F2,B$2:B$9),0))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

  11. #11
    Registered User
    Join Date
    04-29-2013
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Vlookup with multiple matches

    Thank you so much, worked perfectly on my test sheet. Let's hope I can get it to work on the big one!!

    Quote Originally Posted by Tony Valko View Post
    Enter this array formula** in H2 and copy down:

    =INDEX(C$2:C$9,MATCH(G2,IF(A$2:A$9=F2,B$2:B$9),0))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

  12. #12
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Vlookup with multiple matches

    You're welcome. Thanks for the feedback!

+ 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. VLOOKUP with multiple matches
    By SUPPO_USN in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-05-2012, 12:05 AM
  2. Replies: 6
    Last Post: 03-24-2011, 06:19 AM
  3. Multiple VLookup Matches
    By speedy53 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-05-2010, 10:37 AM
  4. need to sum multiple matches from vlookup
    By gmoney123 in forum Excel General
    Replies: 3
    Last Post: 11-09-2009, 10:38 AM
  5. Multiple matches on VLOOKUP
    By [email protected] in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-09-2005, 01:06 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