[英]Excel | Searching table in different sheet and bringing value from column in that row
I am trying to lookup a table in one of my sheets. 我试图在我的一张床单中查找一张桌子。 my table consists of three columns and an unlimited amount of rows. 我的表由三列和无限量的行组成。
My table can be seen here: 我的桌子在这里可以看到:
In my second sheet I wish to write a formula which searches all rows in the table and looks for an exact match in column A and column B, this means it must find the row where column a has a value of "jan" and in that same row the second column must have value "y". 在我的第二张表中,我希望编写一个公式,搜索表中的所有行,并在A列和B列中查找完全匹配,这意味着它必须找到列a的值为“jan”的行,并且第二列的同一行必须具有值“y”。 Should it find this match, it should return the value of column C. 如果找到这个匹配,它应该返回C列的值。
I tried researching hlookup but that is for horizontal tables so i dont believe this would work. 我试过研究hlookup,但那是横向表,所以我不相信这会起作用。 I looked into Vlookups also but that only allows one criteria search instead of looking for two matches. 我也查看了Vlookups,但这只允许一个标准搜索,而不是寻找两个匹配。
Can anyone shed some light here please? 有人可以在这里说清楚吗?
You can use index and match with multiple criteria 您可以使用索引并匹配多个条件
=INDEX($A$1:$C$1000, MATCH("Jan"&"y", $A$1:$A$1000&$B$1:$B$1000, 0),3)
press CTRL + SHIFT + ENTER when entering this formula. 输入此公式时按CTRL + SHIFT + ENTER 。
The INDEX
function has the syntax INDEX
函数具有语法
INDEX(array, row_num_in_array, [column_num_in_array])
And MATCH
returns in the index location of a logic match 并且MATCH
在逻辑匹配的索引位置返回
MATCH(lookup_value, lookup_array, [match_type])
Combining the two is a flexible technique, and surprisingly powerful -- the logic in a match lookup_value can be a complex condition. 将两者结合起来是一种灵活的技术,而且功能非常强大 - 匹配lookup_value中的逻辑可能是一个复杂的条件。
Operate on the whole column 在整个列上操作
INDEX(C:C, MATCH("Jan"&"y", A:A&B:B, 0), 1)
nb./ A:A
is excel code for "all of column A". nb./ A:A
是“所有A列”的excel代码。 You can instead use: 你可以改用:
Operates on a subset of the sheet. 在工作表的子集上运行。
INDEX($C$2:$C$1000, MATCH("Jan"&"y", $A$2:$A$1000&$B$2:$B$1000, 0), 1)
Note that you MUST use identical row length arrays (eg. rows 2:1000) or the formula will not work. 请注意,您必须使用相同的行长度数组(例如,行2:1000),否则公式将不起作用。 MATCH
only knows how many rows into its lookup_array it got, you need to ensure its rows match those in INDEX
's array MATCH
只知道它的lookup_array中有多少行,你需要确保它的行与INDEX
的数组中的行匹配
PS. PS。 apologies this is close to the previous answer, but the details were too long for a comment. 道歉这是接近前一个答案,但细节太长,无法发表评论。
PPS. PPS。 I missed the clarifications to the first answer. 我错过了对第一个答案的澄清。 That will work, but there is no need to use all three columns as the array
in the INDEX
function. 这将起作用,但不需要在INDEX
函数中使用所有三列作为array
。 You are only returning data from column C after all. 毕竟,您只是从C列返回数据。
Convert the range to a table (ctrl-t) and then use SUMIFS to search the table based on two criteria 将范围转换为表(ctrl-t),然后使用SUMIFS根据两个条件搜索表
=SUMIFS(Table1[Alteration],Table1[Month],"Jan",Table1[Products],"y")
This is saying "give me [Alteration] where [Month] = "Jan" and [Products] = 'y'...this returns 364. 这就是说“给我[改变] [月] =”Jan“和[Products] ='y'......这会返回364。
You can point the criteria at separate cells containing your criteria. 您可以将标准指向包含标准的单独单元格。
Be aware that if there is more than one row with identical data (ie more than one row with both 'Jan' and 'y'), column C will be summed together. 请注意,如果有多个行具有相同的数据(即多个行包含'Jan'和'y'),则将C列汇总在一起。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.