Need to find a value that matches two columns of criteria. Possible VLOOKUP

前端 未结 5 1724
不思量自难忘°
不思量自难忘° 2020-12-11 09:05

Update Below -- 6/4

I have two worksheets in excel. One is a list of donors with their check#/amount/ Donor ID ( \"donations\" worksheet) a

5条回答
  •  长情又很酷
    2020-12-11 09:26

    Two column matches typically come in one of two typical configurations; one being an array formula and the other being a standard formula. Both use variations of an INDEX/MATCH function pair.

            Two column Match with INDEX MATCH

    The standard formula for Quickbooks!A2 would be,

    =IFERROR(INDEX(Donations!A$1:A$999, MIN(INDEX(ROW($1:$999)+((Donations!B$1:B$999<>B2)+(Donations!C$1:C$999<>C2))*1E+99, , ))), "No match")
    

    The array formula version for Quickbooks!A2 would be,

    =IFERROR(INDEX(Donations!A$1:A$999, MATCH(1, (Donations!B$1:B$999=B2)*(Donations!C$1:C$999=C2), 0)), "no match")
    

    Array formulas need to be finalized with Ctrl+Shift+Enter↵ rather than simply Enter↵.

    Once one of the formulas has been put in Quickbooks!A2 correctly, fill down as necessary to catch the values from other rows. Note that I have changed the third line of your sample data to demonstrate a second DonationID lookup for Check# 106.

    With ~50K records, there is the distinct possibility that multiple matches could be made on both columns B and C. To capture the subsequent second, third, etc matches from the Donations worksheet, change the MIN function to a SMALL function and use a progressive COUNTIFS function to adjust the k ordinal.

    =IFERROR(INDEX(Donations!A$1:A$50000, SMALL(INDEX(ROW($1:$50000)+((Donations!B$1:B$50000<>B2)+(Donations!C$1:C$50000<>C2))*1E+99, , ), COUNTIFS(B$2:B2, B2, C$2:C2, C2))), "No match")
    

    After setting up some intentional duplicates in the Donations worksheet like this,

    DonationID  Check#  Amount
    179         106    $200 
    210         106    $500 
    220         106    $600 
    979         106    $200 
    910         106    $500 
    920         106    $600 
    

    You should receive results like the following.

            Two column Matches with duplicates

    The IFERROR function has been used to catch non-matches and show no match rather than the #N/A error.

    I have modified the values in your single worksheet sample data to show a variety of matches as well as one case where the chknum and amount were duplicated by two different donationID entries.

        VLOOKUP multiple criteria with duplicates

    The matching records are color-coded for quick reference. I've made this sample workbook publically available at my Docs.com-Preview site.

     VLOOKUP_w_Multiple_Criteria_and_Duplicates.xlsx

提交回复
热议问题