[英]How to lookup multiple columns in excel
You don't need Lookup
, but VLookup
, let me show you:你不需要
Lookup
,但是VLookup
,让我告诉你:
=VLOOKUP(D4,$D$4:$H$20,2,FALSE)
This means (in case "Mary" is put in cell D4): go look in to D4:H20 (made invariable using the dollar signs), and take the second column (containing the "D") variable.这意味着(如果“Mary”放在单元格 D4 中): go 查看 D4:H20(使用美元符号保持不变),然后取第二列(包含“D”)变量。
If you want to find "J" (third column), use:如果要查找“J”(第三列),请使用:
=VLOOKUP(D4,$D$4:$H$4,3,FALSE)
If you want to find "P" (fourth column):如果要查找“P”(第四列):
=VLOOKUP(D4,$D$4:$H$4,4,FALSE)
The last parameter is just for having an exact search.最后一个参数仅用于进行精确搜索。
You can use INDEX MATCH based approach like this:您可以像这样使用基于 INDEX MATCH 的方法:
=INDEX(G1:G6,SUM((H1:L6=D1)*ROW(H1:L6)))
If you have a version of Excel older than 2016, you will have to enter this formula with CTRL+SHIFT+ENTER.如果您的 Excel 版本早于 2016 年,则必须使用 CTRL+SHIFT+ENTER 输入此公式。
NOTE - this only works if the table starts in row 1.
注意 - 这仅在表格从第 1 行开始时才有效。
So to make it more general, you could do:因此,为了使其更通用,您可以执行以下操作:
=INDEX(G1:G6,SUM((H1:L6=D1)*(ROW(H1:L6)-ROW(H1)+1)))
Another shorter option, can return single or multiple match.另一个较短的选项,可以返回单个或多个匹配项。
In D2
, enter formula:在
D2
中,输入公式:
=TEXTJOIN(", ",,IF(H1:L6=D1,G1:G6,""))
For Excel 2019, It will have to enter this formula with CTRL+SHIFT+ENTER.对于 Excel 2019,必须使用 CTRL+SHIFT+ENTER 输入此公式。
For Office 365, it will normal entry.对于Office 365,它将正常进入。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.