简体   繁体   English

在 Excel 数组公式结果中查找匹配项

[英]Find matches within an Excel array formula result

I am looking for a way do some kind of nested/indirect lookup.我正在寻找一种方法进行某种嵌套/间接查找。

  1. I have a table of two columns with car models (eg Mustang) in column A and their makes (eg Ford) in column B我有一个两列的表格,A 列中有汽车型号(例如 Mustang),B 列中有它们的品牌(例如福特)
  2. In column FI have a list of car models.在列 FI 中有一个汽车型号列表。 This can be models that are listed in column A, but not all models of column A have te be listed in F这可以是列在 A 列中的型号,但并非所有列 A 的型号都列在 F 中
  3. Column D contains some car makes. D 列包含一些汽车品牌。

For each car make in column DI need to determine whether there exists a model that is present in column F. So with the car make in a of D, I want to look up the corresponding care models in column B and next I want to look for occurrences of these found care models in column F.对于列 DI 中的每个汽车品牌,需要确定是否存在存在于 F 列中的模型。因此,对于 D 列中的汽车品牌,我想在 B 列中查找相应的保养模型,然后我想查看对于这些发现的护理模型在 F 列中的出现。

I succeed to do the first lookup using an array formula, however I am stuck on how to determine whether the resulting array and the range in F have common elements (or a non-empty intersection).我成功地使用数组公式进行了第一次查找,但是我坚持如何确定结果数组和 F 中的范围是否具有公共元素(或非空交集)。

Any help will be appreciated!任何帮助将不胜感激!

henkgijsbert亨吉斯伯特

A(Model) B(Make) C(empty) D(=Make2) E(=Found) F(=carlist) A(型号) B(制造) C(空) D(=Make2) E(=Found) F(=carlist)

Corvette Chevrolet Dodge (1)?克尔维特雪佛兰道奇 (1)? Corvette克尔维特
Camaro Chevrolet Chevrolet (2)? Camaro 雪佛兰雪佛兰 (2)? Mustang野马
Mondeo Ford Camaro蒙迪欧福特科迈罗
Mustang Ford野马福特
Challenger Dodge挑战者道奇
Avenger Dodge复仇者道奇

In the example above, on (1) the result should be N, because there are care no models in column F of the make D1 ("Dodge").在上面的例子中,在 (1) 上的结果应该是 N,因为在制造 D1(“道奇”)的 F 列中没有模型。 On (2) the result should be Y, because there are models (even 2) in column F of the make D2 ("Chevrolet").在 (2) 上,结果应该是 Y,因为在制造 D2(“雪佛兰”)的 F 列中有模型(甚至 2)。

I have the following array-formula gets all models for the Make "Dodge" in D1:我有以下数组公式获取 D1 中 Make“Dodge”的所有模型:

{=IFERROR(INDEX($A$1:$A$6; SMALL(IF(D1=$B$1:$B$6; ROW($A$1:$A$6);""); ROW()));"")}

How can I compare the result of this array-formula with matches in column F?如何将此数组公式的结果与 F 列中的匹配项进行比较?

You can enter the following in E3 and drag down. 您可以在E3中输入以下内容并向下拖动。 Enter formula with Ctrl + Shift + Enter ie as an array formula. 使用Ctrl + Shift + Enter输入公式,即作为数组公式。

 =IF(SUMPRODUCT(--ISNUMBER(MATCH($F$3:$F$5,IF(ISNUMBER(SEARCH($D3,$B$3:$B$8)),$A$3:$A$8,""),0)))>0,"Y","N")

Data: 数据:

在此处输入图片说明

If you don't want to lookup the make into column G, you can use this formula: 如果您不想在G列中查找品牌,则可以使用以下公式:

=IF(0<SUM(MMULT(--(TRANSPOSE($A$2:$A$7)=$F$2:$F$3),--($B$2:$B$7=$D2))),"Y","N")

But I would recommend to create a Make2 column in G, that would be much easier to understand later. 但是我建议在G中创建一个Make2列,这以后会更容易理解。

Another option. 另外一个选项。

Use your current array formula and nest it in a COUNTIF and an IF statement. 使用当前的数组公式并将其嵌套在COUNTIFIF语句中。

{=IF(COUNTIF($F$1:$F$3;IFERROR(INDEX($A$1:$A$6; SMALL(IF(D1=$B$1:$B$6; ROW($A$1:$A$6);""); ROW()));""))>0;"Y";"N")}

COUNTIF counts how many times your original formula find any value in carlist. COUNTIF计算原始公式在carlist中发现任何值的次数。

COUNTIF($F$1:$F$3;IFERROR(INDEX($A$1:$A$6; SMALL(IF(D1=$B$1:$B$6; ROW($A$1:$A$6);""); ROW()));""))>0

If the finding is greater than 0 (at least one match is found) then return yes by the IF formula: 如果发现结果大于0(找到至少一个匹配项),则通过IF公式返回yes:

IF(logic expression>0; "Y"; "N").

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

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