How can I search through an Excel array to find specific text and then generate a new array that contains the values from those cells?

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

How can I search through an Excel array to find specific text and then generate a new array that contains the values from those cells?

问题

我有一个大量的有机化合物列表,其中一些含氯,而一些不含氯。我尝试编写一个函数,它会浏览有机化合物列表并生成一个新的仅包含含氯化合物的数组。以下是我目前的结果:

可以看到,该函数正确地提取了所有含氯化合物,但理想情况下,我希望得到一个忽略所有不符合条件的化合物而不是返回“no”值的列表。我在这里漏掉了什么?

英文:

I have a large list of organic compounds, some of which are chlorinated and some are not. I have tried to write a function that looks through the list of organic compounds and generates a new array of only those compounds which are chlorinated. Here is the result I have so far:

You can see that the function is correctly pulling all chlorinated compounds, but ideally I'd like to have a list that ignores all compounds which do not meet the criteria instead of returning a "no" value. What am I missing here?

How can I search through an Excel array to find specific text and then generate a new array that contains the values from those cells?

答案1

得分: 1

以下是您要翻译的内容:

根据OP的要求,将其作为答案发布。

How can I search through an Excel array to find specific text and then generate a new array that contains the values from those cells?


使用 FILTER() 函数可以完成任务,只需忽略 IF() 部分。

也就是说,公式将是:

=FILTER(A3:A83,ISNUMBER(SEARCH("chl",A3:A83)),"")

英文:

As asked by OP, posting it as answer.

How can I search through an Excel array to find specific text and then generate a new array that contains the values from those cells?


Using FILTER() Function does the job, only have to scrap the IF() part.

That said the formula will be:

=FILTER(A3:A83,ISNUMBER(SEARCH("chl",A3:A83)),"")

huangapple
  • 本文由 发表于 2023年5月17日 22:43:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/76273352.html
匿名

发表评论

匿名网友

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

确定