数组搜索的多个匹配结果 [英] Multiple Match Results From Array Search
问题描述
为了MWE,我有一个$ AP $ 4:$ BO $ 20的数组,每个单元格中都有一个字符串。每个单元格中的数据是一个字母数字代码,例如1,1a,2b,3c等。
从列AQ开始,第22行包含一个单个字符串匹配上面列出的数组中的一个或多个字符串。目标:使用AQ22:AO22中的每个字符串,创建一个公式,提取数组$ AP $ 4:$ BO $ 20中的每个单元格行数,其中包含AQ22:AO22中的值。
无需使用数组公式即可实现此功能。 VBA不是一个选择,因为这是Google表格,我更希望避免使用g-apps-script。
我尝试使用
= INDIRECT(ADDRESS(MIN(IF(NOT(ISERROR(FIND(AQ22,$ AP $ 4:$ BO $ 20,1))),ROW ($ AP $ 4:$ BO $ 20),)),1))
p>
= IFERROR(INDEX($ AP $ 4:$ BO $ 20,SMALL(IF($ AP $ 4:$ BO $ 20 = AQ22,ROW ($ AP $ 4:$ BO $ 20)-4),ROW(A1)),2),)
甚至是杰出的
= IF(ISERROR(INDEX($ AP $ 4:$ BO $ 20,SMALL ($ AP $ 4:$ BO $ 20 = AQ22,ROW($ AP $ 4:$ BO $ 20)),ROW(1:1)),2)), ,INDEX($ AP $ 4:$ BO $ 20中,SMALL( IF($ AP $ 4:$ BO $ 20 = AQ22,ROW($ AP $ 4:$ BO $ 20)),ROW(1:1)),2))
这是一个玩具表使用这些信息来测试想法。请注意公式开始的单元格上的注释。
不知道如果我正确理解了所需的结果, ($ AL $ 4:$ AL $ 16),RegExMatch($ AL $ 4:$ AL $ 16,\\$$$ \\ b& AQ22&\b)),)
7,$ code> 7 和 9
。 \b
是字边界匹配字母数字和非字母数字字符。如果要将结果存储在一个单元格中,可以加入它们:
= IfError(Join(,,Filter ($ AL $ 4:$ AL $ 16),RegExMatch($ AL $ 4:$ AL $ 16,\b& AQ22&\b))),)
您还可以匹配多个值:
= IfError(Filter(Row($ AL $ 4:$ AL $ 16),RegExMatch($ AL $ 4:$ AL $ 16,\b(& Join(|,AQ22:AZ22)& \\ b)),)
For the sake of MWE, I have an array in $AP$4:$BO$20 with a single string in each cell. The data in each cell is an alphanumeric code, such as 1,1a,2b,3c, etc.
Row 22, starting in column AQ, contains a single string that matches one or more of the strings in the array named above. Goal: using each string in AQ22:AO22, create a formula that extracts EVERY row number of the cells in the array $AP$4:$BO$20 that contain exactly the value in AQ22:AO22.
Bonus for doing it without using an array formula. VBA is not an option since this is Google Sheets, and I'd really prefer to avoid g-apps-script.
I've attempted using
=INDIRECT(ADDRESS(MIN(IF(NOT(ISERROR(FIND(AQ22,$AP$4:$BO$20,1))),ROW($AP$4:$BO$20),"")),1))
and
=IFERROR(INDEX($AP$4:$BO$20,SMALL(IF($AP$4:$BO$20=AQ22,ROW($AP$4:$BO$20)-4),ROW(A1)),2),"")
and even the illustrious
=IF(ISERROR(INDEX($AP$4:$BO$20,SMALL(IF($AP$4:$BO$20=AQ22,ROW($AP$4:$BO$20)),ROW(1:1)),2)),"",INDEX($AP$4:$BO$20,SMALL(IF($AP$4:$BO$20=AQ22,ROW($AP$4:$BO$20)),ROW(1:1)),2))
Here is a toy sheet to test out ideas with using this information. Note the comment on the cell where the formula will begin.
Not sure if I understand the desired result correctly, but
= IfError( Filter( Row($AL$4:$AL$16), RegExMatch( $AL$4:$AL$16, "\b" & AQ22 & "\b" ) ), "")
results in 7
, and 9
in a separate cell below it. \b
is a word boundary that matches between alphanumeric and non-alphanumeric character. If you want the result in one cell, you can join them:
=IfError(Join(",", Filter(Row($AL$4:$AL$16), RegExMatch($AL$4:$AL$16, "\b"&AQ22&"\b"))), "")
You can also match multiple values:
=IfError(Filter(Row($AL$4:$AL$16), RegExMatch($AL$4:$AL$16, "\b(" & Join("|", AQ22:AZ22) & ")\b")), "")
这篇关于数组搜索的多个匹配结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!