简体   繁体   English

Excel | 在不同工作表中搜索表并从该行中的列中获取值

[英]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中的逻辑可能是一个复杂的条件。

SIMPLEST CODE 最简单的代码

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: 你可以改用:

RESTRICTED CODE 限制代码

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.

相关问题 如何通过查找列中的值从不同的 excel 工作表返回整行? - How do I return an entire row from a different excel sheet by looking up a value in a column? Excel-用另一张纸上一行的内容填充列标题 - Excel - populating a column header with contents from a row on a different sheet 根据列中的值填充其他工作表中的excel单元格值 - Populate excel cell value from a different sheet based on value in a column 在MS Excel工作表中创建公式以从行和列中获取值 - creating formula in MS excel sheet to fetch value from row and column 验证工作表中两列的值,并将值插入到Excel不同工作表的另一列中 - Validation of value from two column of a sheet with insertion of value in another column of different sheet of an excel 搜索给定值后,将excel中的一行从一张纸复制到另一张纸 - Copying a row in excel from one sheet to another after searching for a given value Excel宏从一张工作表中搜索第1行中的某些文本,复制该文本下的列,然后粘贴到另一张工作表中 - Excel Macro to search certain texts in row 1 from one sheet, copy the column under the text, and paste to a different sheet Excel:如果列中的单元格= X的文本值,则在另一个工作表上显示文本(在同一行,但不同的列) - Excel: If Cell in Column = text value of X, then display text (in the same row, but different column) on another sheet Excel基于一个列的值将整个行从一张纸复制到另一张纸 - Excel Copy whole row from a sheet to another sheet based on one column value VBA从Sheet1 +中的唯一列值创建新工作表,以转移相邻行的信息 - VBA Creating new sheets from unique column values in Sheet1 + bringing over adjacent row information
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM