简体   繁体   English

excel查找索引匹配公式的第二个匹配项

[英]excel find the second match to an index match formula

I have the following formula: 我有以下公式:

=INDEX(A:A;MATCH(1;(B:B=H1)*(C:C=I1)*(NOT(ISBLANK(D:D))))*((ISBLANK(E:E))));0))

now i want to pull the second result from the A:A column that matches this formula and the conditions in the match function. 现在我想从A:A列中提取第二个结果,该列与此公式和match函数中的条件匹配。 With this function, I only get the ABCDE which is the first match(result), but there is another FGHI that also matches this formula. 使用此功能,我只会得到第一个匹配(结果)的ABCDE,但是还有另一个FGHI也与此公式匹配。 But it comes several cells below the first one. 但是它比第一个单元格少几个单元格。 My first match is ABCDE, and my second match is FGHI. 我的第一场比赛是ABCDE,而我的第二场比赛是FGHI。 I want to fetch the latter. 我想获取后者。 I have tried different ways, but I can't get around this one. 我尝试了不同的方法,但无法解决这一问题。 Please help me in this regard. 请在这方面帮助我。 thank you. 谢谢。

You are going to want to cut down the full column references to something that more closely approximates the actual extents of your data. 您将希望将整列引用缩减为更接近数据实际范围的内容。 My preferred method is to incorporate SMALL against an INDEX array of row numbers that will replace the MATCH in your original formula. 我的首选方法是将SMALL与行号的INDEX数组合并,该数组将替换原始公式中的MATCH

=INDEX(A$2:A$9999; SMALL(INDEX(ROW($1:$9998)+((B$2:B$9999<>H1)+(C$2:C$9999<>I1)+NOT(LEN(D$2:D$9999))+NOT(LEN(E$2:E$9999)))*1E+99;;); ROW(1:1)))

I used a simple Find & Replace to change my comma list separators to semi-colons so I apologize if that needs minor editing to work on your system, 我使用了一个简单的“查找和替换”将逗号列表分隔符更改为分号,因此如果您需要进行少量编辑才能在您的系统上工作,我深表歉意,

When transcribing for your own purposes, remember that ROW($1:$9998) is the position within A$2:A$9999 and not the actual row on the worksheet. 当录制自己的目的,请记住, ROW($1:$9998) A $ 2的位置 :A $ 9999不工作表上的实际行。 ROW(1:1) is simply an incremental counter for SMALL that will provide 1, 2, 3, etc as you fill down. ROW(1:1)只是SMALL的增量计数器在您填充时将提供1、2、3等

WOW! 哇! Thanks. 谢谢。 Here is the ultimate working version. 这是最终的工作版本。 I had minor errors in my adaptation: 我的改编有一些小错误:

=INDEX(INDIRECT("'"&file_list!$C$3&"'!$F$2:$F$999"); SMALL(INDEX(ROW(INDIRECT("'"&file_list!$C$3&"'!$1:$998"))+((INDIRECT("'"&file_list!$C$3&"'!$B$2:$B$999")<>parameters!$C$3)+(INDIRECT("'"&file_list!$C$3&"'!$i$2:$i$999")<>parameters!$A$2)+NOT(LEN(INDIRECT("'"&file_list!$C$3&"'!$d$2:$d$999")))+(LEN(INDIRECT("'"&file_list!$C$3&"'!$H$2:$H$999"))))*1E+99;;); ROW(INDIRECT("'"&file_list!$C$3&"'!$2:$2"))))

You are a hero. 你是英雄。

Addendum by Jeeped: 吉普的附录:

I'm nowhere near a hero until you understand how that actually works. 除非您了解这是如何工作的,否则我离英雄很远。 I tried to put this in a comment but I was too long by half so I am using my editing privileges in the hope of clarification. 我尝试将其添加到注释中,但由于时间太长,因此我正在使用自己的编辑权限以期澄清。

It's very important to understand how that combination of Excel native functions works if you hope to use the principals in the future. 如果您希望将来使用这些主体,那么了解Excel本机功能的组合如何工作非常重要。 The first ROW(INDIRECT("'"&file_list!$C$3&"'!$1:$998") will work as written but would be better as ROW($1:$998") . This is just returning a number (ie matching row within "'"&file_list!$C$3&"'!$F$2:$F$999" . It does not matter where the number comes from. The conditions further into the formula determine whether it is a valid row number or not and those DO require the worksheet name from file_list!$C$3 because their cell value is being examined. 第一个ROW(INDIRECT("'"&file_list!$C$3&"'!$1:$998")将按书面形式工作,但会比ROW($1:$998")更好。这只是返回一个数字(即匹配的行)在"'"&file_list!$C$3&"'!$F$2:$F$999" 。数字的来源无关紧要。公式中的条件决定了它是否为有效的行号,以及确实需要file_list!$C$3的工作表名称,因为正在检查其单元格值。

In a similar manner ROW(INDIRECT("'"&file_list!$C$3&"'!$2:$2")) should be ROW(2:2) if you want the second matching row within '"&file_list!$C$3&"'!$F$2:$F$999" . This portion of the formula is just an increment for SMALL . If you put row(1:1) in a cell and fill down you will get 1, 2, 3, etc . This transfers into the SMALL function as SMALL(<a bunch of matching row numbers>, first) then SMALL(<a bunch of matching row numbers>, second) then SMALL(<a bunch of matching row numbers>, third) etc. You are not trying to return Sheet1!A1,Sheet1!A2,Sheet1!A3,etc . Allk you want is 1, 2, 3, etc to stuff into SMALL as the k parameter. 以类似的方式,如果您想要'"&file_list!$C$3&"'!$F$2:$F$999"第二个匹配行,ROW(INDIRECT("'"&file_list!$C$3&"'!$2:$2"))应该为ROW(2:2) '"&file_list!$C$3&"'!$F$2:$F$999" 。公式的这一部分只是SMALL的增量。如果将row(1:1)放在单元格中并填写,您将得到1,2,3等 。这将以SMALL(<a bunch of matching row numbers>, first)然后SMALL(<a bunch of matching row numbers>, second)然后SMALL(<a bunch of matching row numbers>, third)等形式转移到SMALL函数中。您不是要返回Sheet1!A1,Sheet1!A2,Sheet1!A3等 。您想要的Allk是1,2,3等 ,作为k参数填充到SMALL中。

The Office.Microsoft.com Excel function reference are not always the most helpful place to go but here they are anyways. Office.Microsoft.com Excel函数参考不一定总是最有用的地方,但是无论如何它们还是在这里。

ROW function ROW功能

SMALL function 小功能

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

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