使用 INDEX 和 MATCH 在 table 数组中查找两列
Two column lookup in table array using INDEX and MATCH
我希望 excel 使用 INDEX
和 [=15] 显示具有两个匹配单元格 com_cd
和 div_cd
的 table 数组的值=].
我尝试了以下公式,但没有用。
=INDEX(K9:K53,MATCH(K3,I9:I53,0),MATCH(K4,J9:J53,0))
这是 excel sheet 的屏幕截图,根据 com_cd
和 div_cd
给出了所需的结果
尝试使用数组公式 (CTRL + SHIFT + ENTER)
而不是 Enter
。
=INDEX(K9:K53,MATCH(K3&K4,I9:I53&J9:J53,0),1)
未测试但应该可以。
稍后将编辑解释我们的公式以及您的公式不起作用的原因。
您在 INDEX function 上的 column_num 参数不能简单地提供辅助行标准。您需要一种方法来确保 row_num 参数上的两列匹配,并将 column_num 留空或保留为1(K9:K53
只有一列)。
K5的标准公式应该是,
=index(K9:K53, aggregate(15, 6, row(1:45)/((i9:i53=k3)*(j9:j53=k4)), 1))
...或者,
=index(K9:K53, min(index(row(1:45)+((i9:i53<>k3)+(j9:j53<>k4))*1e99, , )))
单元格区域 K9:K53 共有 45 行。 K9:K53 内的位置将在 ROW(1:45)
内。第一个公式强制任何不匹配的行进入 #DIV/0!
错误状态和 AGGREGATE¹ function uses option 6 to ignore errors while retrieving the smallest valid entry with the SMALL sub-function (e.g. 15). The second formula performs the same action by adding 1E+99 (a 1 followed by 99 zeroes) to any non-matching row and taking the smallest matching row with the MIN function.
¹ AGGREGATE function 是在 Excel 2010 中引入的。它在早期版本中不可用。
我希望 excel 使用 INDEX
和 [=15] 显示具有两个匹配单元格 com_cd
和 div_cd
的 table 数组的值=].
我尝试了以下公式,但没有用。
=INDEX(K9:K53,MATCH(K3,I9:I53,0),MATCH(K4,J9:J53,0))
这是 excel sheet 的屏幕截图,根据 com_cd
和 div_cd
尝试使用数组公式 (CTRL + SHIFT + ENTER)
而不是 Enter
。
=INDEX(K9:K53,MATCH(K3&K4,I9:I53&J9:J53,0),1)
未测试但应该可以。
稍后将编辑解释我们的公式以及您的公式不起作用的原因。
您在 INDEX function 上的 column_num 参数不能简单地提供辅助行标准。您需要一种方法来确保 row_num 参数上的两列匹配,并将 column_num 留空或保留为1(K9:K53
只有一列)。
K5的标准公式应该是,
=index(K9:K53, aggregate(15, 6, row(1:45)/((i9:i53=k3)*(j9:j53=k4)), 1))
...或者,
=index(K9:K53, min(index(row(1:45)+((i9:i53<>k3)+(j9:j53<>k4))*1e99, , )))
单元格区域 K9:K53 共有 45 行。 K9:K53 内的位置将在 ROW(1:45)
内。第一个公式强制任何不匹配的行进入 #DIV/0!
错误状态和 AGGREGATE¹ function uses option 6 to ignore errors while retrieving the smallest valid entry with the SMALL sub-function (e.g. 15). The second formula performs the same action by adding 1E+99 (a 1 followed by 99 zeroes) to any non-matching row and taking the smallest matching row with the MIN function.
¹ AGGREGATE function 是在 Excel 2010 中引入的。它在早期版本中不可用。