简体   繁体   English

Excel - 根据多个标准检索单元格

[英]Excel - Retrieving a cell based off of multiple criteria

I am attempting to return the value of a cell from within a different sheet based upon two cell values in the second sheet.我正在尝试根据第二张工作表中的两个单元格值从不同工作表中返回一个单元格的值。 As an example the Main and Second sheet have three columns each (Item, Code, Number), the difference being that the second sheet has only one row and two drop down lists that are populated with the Item(s) and Code(s) (from the Main sheet - ie like a database table).例如,工作表和第二工作表各有三列(项目、代码、编号),不同之处在于第二个工作表只有一行和两个下拉列表,其中填充了项目和代码(来自表 - 即像数据库表)。 From within the Second sheet I would like the Number to be returned from the main sheet, once the Item and Code had been selected from the drop down lists on the Second sheet.第二张表中,一旦从第二张表的下拉列表中选择了项目和代码,我希望从主表中返回数字。

Unfortunately I'm unsure as how to do this based off of multiple criteria.不幸的是,我不确定如何根据多个标准来做到这一点。 As far as I'm aware VLOOKUP only used one criteria over a range.据我所知,VLOOKUP 只在一个范围内使用了一个标准。 I've attempted the following below which is accepted by Excel as a valid formula, however it doesn't return the correct value.我尝试了以下被 Excel 接受为有效公式的方法,但是它没有返回正确的值。

{=SUMPRODUCT((Main!A:A='Second'!A7) * (Main!C:C='Second'!E2) * (Main!G:G))}

I've interpreted the above as the first two sets of brackets being the range and condition to match and the last set being the range of values to return from.我将上面的内容解释为前两组括号是要匹配的范围和条件,最后一组是要返回的值的范围。 Is this a correct assumption and is this the correct use of that function?这是一个正确的假设吗?这是 function 的正确使用吗?

Are there any other functions I could use?还有其他我可以使用的功能吗?

Thank you, I have very little experience with Excel!谢谢,我对Excel的经验很少!

Have you taken a look at the magic INDEX combined with MATCH , and perhaps MATCH again?您是否看过与MATCH结合的神奇INDEX ,也许又是MATCH

INDEX returns the contents of a cell from a table provided a row and a column. INDEX从提供行和列的表格中返回单元格的内容。 Usage:用法:

=INDEX([table to look in]; [COLUMN index]; [ROW index])

MATCH returns the indexes that match a criteria in the table. MATCH返回与表中的条件匹配的索引。 Usage:用法:

=MATCH([Criteria];[table to look in])

And you can nest one inside the other the following way:您可以通过以下方式将一个嵌套在另一个内部:

=INDEX([table to look for in];MATCH([Criteria];[Table to look for the particular Row]);[COLUMN, or a second MATCH to find the right column])

Or even combine a couple of MATCH as in或者甚至结合几个MATCH ,如

=INDEX([table to look for in];AND(MATCH(1);MATCH(2)); [Column to look for, or MATCH to look for in column])

Which I think is what you want.我认为这是你想要的。

If you need a SUM of something (as you used a SUM function before), just nest it inside the proper SUM function如果您需要某物的总和(因为您之前使用了 SUM function),只需将其嵌套在正确的 SUM function 中

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

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