简体   繁体   English

具有两个条件的Excel查找公式

[英]Excel Lookup Formula with Two Conditions

Sorry about the heading but im finding it hard to explain so ill give it my best shot. 对标题感到抱歉,但我发现很难解释,因此请尽我所能。

Here is my problem I have 3 cells: Lender, product and productID I have a vlookup that fills the lender and product cells just fine However i want a way to bring back the productID back from another worksheet matching with lender and product. 这是我的问题,我有3个单元:借方,产品和productID我有一个vlookup可以很好地填充借方和产品单元格,但是我想要一种从与借方和产品匹配的另一个工作表中取回productID的方法。

For instance if call1 = newcastle and cell2 = 2 year fixed then cell3 = 422 例如,如果call1 =新堡,cell2 =固定2年,则cell3 = 422 在此处输入图片说明

I tried using a vlookup but doesnt seem to work, Any help on this would be greatly appreciated. 我尝试使用vlookup,但似乎无法正常工作,对此将大有帮助。 Thanks 谢谢

You can use Index and Match to perform a lookup with two criteria. 您可以使用“ Index和“ Match以两个条件执行查找。 Here is an example of one from http://blog.contextures.com/archives/2012/07/12/check-multiple-criteria-with-excel-index-and-match/ 这是一个http://blog.contextures.com/archives/2012/07/12/check-multiple-criteria-with-excel-index-and-match/中的示例

=INDEX($D$2:$D$10,MATCH(1,(A13=$B$2:$B$10)*(B13=$C$2:$C$10),0))

As mentioned on the site, it is an array formula so rather than just pressing enter when you use the formula, you need to hold Ctrl + Shift + Enter . 如站点上所提到的,它是一个数组公式,因此在使用公式时,您不仅需要按住Ctrl + Shift + Enter键 ,还需要 Enter键

To break down how the formula is formatted: 要分解公式的格式,请执行以下操作:

=INDEX(a,MATCH(1,(b=c)*(d=e),0))
  • a = The whole range with all the data in it a =包含所有数据的整个范围
  • b = The first criteria for the data to be filtered on b =要过滤的数据的第一个条件
  • c = The range in which the first criteria needs to be searched c =需要搜索第一个条件的范围
  • d = The second criteria for the data to be filtered on d =要过滤的数据的第二个标准
  • e = The range in which the second criteria needs to be searched e =需要搜索第二个条件的范围

Make sure that you use $ in the correct places as in the above example. 确保如上例所示,在正确的位置使用$

Let's say that Newcastle is in A2 and 2 year fixed is in B2. 假设纽卡斯尔在A2中, 固定2年在B2中。 It doesn't matter what worksheet they are on.In another worksheet named Data you have a table with a column of lenders in column X, products in column Y and product IDs in column Z. There are column labels in row 1 so the real data starts in row 2 and there are 2587 rows of data. 它们在什么工作表上都没有关系。在另一个名为“ 数据”的工作表中,您有一个表,其中在X列中有一个贷方列,在Y列中有产品,在Z列中有产品ID。第1行有列标签,因此实际数据从第2行开始,共有2587行数据。 In the first worksheet's C2 where you want the double lookup for a ProductID that matches Lende and Product try this formula. 在第一个工作表的C2中,您需要双重查找与LendeProduct匹配的ProductID ,请尝试以下公式。

=IFERROR(INDEX('Data'!$Z$2:$Z$9999, MIN(INDEX(ROW($1:$9998)+(('Data'!$X$2:$X$9999<>$A2)+('Data'!$Y$2:$Y$9999<>$B2))*1E99,,))), "no match")

Another alternative to using combination of the MATCH and INDEX functions that some may find more straightforward is to first insert a column on your lookup table and concatenate the cobmination of columns you wish to search by. 有些人可能会发现,使用MATCH和INDEX函数的组合的另一种替代方法是首先在查询表中插入一列,然后将希望搜索的列合并在一起。

=CONCATENATE(B8,C8) = CONCATENATE(B8,C8)

Then you can still use the Vlookup function, but instead of only entering the one column to lookup on, you would combined them in the lookup so that the combination of them looks up to the combination of them on the lookup table. 然后,您仍然可以使用Vlookup函数,但是您不仅可以在查找中合并它们,还可以在查找表中查找它们的组合,而不是仅输入一列进行查找。

=VLOOKUP(B3&C3,A9:D10,4,0) = VLOOKUP(B3&C3,A9:D10,4,0)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM