基于数值范围进行筛选

huangapple go评论64阅读模式
英文:

Filter based on a range of Values

问题

=REGEXMATCH(B:B, INDIRECT("Sheet2!D1"))

=REGEXMATCH(B:B, JOIN("|", Sheet2!D1:D2))

英文:

OK - So imagine I have a column with a number of street addresses:

1 Fred St
7 John St
3 Fred Avenue
12 John St
15 Alex st

In another sheet, I have a series of street names in which I am interested:

John
Fred

I want to filter the first sheet to display rows which contain either John or Fred. I've tried a filter based on a custom formula. This will find all the ones with John:

=REGEXMATCH(A:A, "John")

and this will work if John is in D1

=REGEXMATCH(B:B, $D$1)

First how do I get this latter one to work if D1 is in a different sheet? Can I prefix the sheet name somehow? Secondly, how do I get it to work based on a series of different values (like John and Fred) stored elsewhere.

=REGEXMATCH(B:B, $D$1:$D$2)

答案1

得分: 0

你可以使用TEXTJOIN来连接一个范围内的所有单元格,避免空单元格:例如,这个公式将会使用列D中的所有值。显然,如果你想要的话,你可以缩小范围,但这只是为了向你展示:

=REGEXMATCH(B:B, TEXTJOIN("|",1,$D$1:$D))
英文:

You can use TEXTJOIN to concatenate all the cells of a range, avoiding empty cells: for example, this formula would take all column D. Obviously you can narrow it if you want, but just to show you:

=REGEXMATCH(B:B, TEXTJOIN("|",1,$D$1:$D))

答案2

得分: 0

=REGEXMATCH()将以简单方式工作,您也可以尝试以下-

=LAMBDA(lm,FILTER(lm,
MAP(lm,LAMBDA(x,OR(INDEX(ISNUMBER(SEARCH(SPLIT(x," "),TEXTJOIN("|",1,H2:H)))))))))
(A2:INDEX(A2:A,COUNTA(A2:A)))

基于数值范围进行筛选

英文:

While REGEXMATCH() will work in simple manner, you may also try the following-

=LAMBDA(lm,FILTER(lm,
MAP(lm,LAMBDA(x,OR(INDEX(ISNUMBER(SEARCH(SPLIT(x," "),TEXTJOIN("|",1,H2:H)))))))))
(A2:INDEX(A2:A,COUNTA(A2:A)))

基于数值范围进行筛选

huangapple
  • 本文由 发表于 2023年3月23日 09:16:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/75818508.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定