简体   繁体   English

在excel中查找多个值

[英]Lookup multiple values in excel

Is there a way for excel formulas to look up multiple values in an 2d matrix for excel? 有没有办法让excel公式在excel的2d矩阵中查找多个值? For example: 例如:

sum(vlookup({2015,2016},Matrix,{2,4,6},False)) = 3 + 4 + 5 + 2 + 3 + 2 

2014  1    3    7    11   9    2
2015  3    6    4    12   5    8
2016  2    1    3    99   2    6

I don't necessarily have to use the function vlookup but I prefer not having to use the same function multiple times then summing them since the list {2015,2016} could be quite long. 我不一定要使用函数vlookup,但我更喜欢不必多次使用相同的函数然后对它们进行求和,因为列表{2015,2016}可能会很长。

Put your search criteria in one cell each: 将搜索条件分别放在一个单元格中:

在此输入图像描述

Then use this formula: 然后使用这个公式:

=SUMPRODUCT(ISNUMBER(SEARCH($A$1:$A$3,J1))*ISNUMBER(SEARCH(COLUMN($B$1:$G$3),K1))*$B$1:$G$3)

在此输入图像描述


If you want to hard code the numbers then you can do it this way: 如果您想对数字进行硬编码,那么您可以这样做:

=SUMPRODUCT(ISNUMBER(SEARCH($A$1:$A$3,"2015,2016"))*ISNUMBER(SEARCH(COLUMN($B$1:$G$3),"2,4,6"))*$B$1:$G$3)

I like @ScottCraner's answer a lot, I just did it slightly differently, but using close-on the same tricks. 我非常喜欢@ ScottCraner的答案,我只是稍微不同,但使用了相同的技巧。

For me, I put the year values in as follows in column N: 对我来说,我将年份值列在N列中:

N1 = 2015
N2 = 2016

And the columns I wanted to use for the look-up in column O: 我希望用于O列中查找的列:

O1 = 2
O2 = 4
O3 = 6

Then, I used the following ( entered as an array formula - meaning you press CTRL+SHIFT+ENTER after putting it in): 然后,我使用以下( 作为数组公式输入 - 意味着你把它放入后按CTRL + SHIFT + ENTER):

=SUMPRODUCT(ISNUMBER(MATCH(A1:A3,$N$1:$N$2,0))*ISNUMBER(MATCH(COLUMN(A1:G3)-COLUMN(A1)+1,$O$1:$O$3,0))*A1:G3)

Again, Scott's answer is perfectly right, I just added in a different way to get to the same result. 同样,斯科特的答案是完全正确的,我只是以不同的方式添加以获得相同的结果。

Hope it helps you or someone else facing the same kind of challenge. 希望它可以帮助您或其他面临同样挑战的人。

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

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