简体   繁体   English

Excel:如何将条件应用于数组中的每个单元格?

[英]Excel : How to apply a criterion to each cell in an array?

在此处输入图片说明

So in the example above, I would like to extract all cells that contain "A" as the first letter(and length=9, though it does not matter). 因此,在上面的示例中,我想提取所有包含“ A”作为第一个字母(长度为9,尽管没有关系)的单元格。
Now I am able to run the function for one cell, but I want to run it as an array formula so that I do not have to drag down 1000 cells every time. 现在,我可以为一个单元格运行该函数,但是我想将其作为数组公式运行,这样我就不必每次都拖动1000个单元格。 Below is my code: 下面是我的代码:

=IFERROR(INDEX($A$1:$A$3, IF(AND(LEFT(A2,1)="A", LEN(A2)=9), ROW($A$1:$A$3),"")),"")

The problem here is that when I enter the code with "Ctrl + Shift + Enter", the criteria would be only confined to A2, which is the cell address I manually entered. 这里的问题是,当我使用“ Ctrl + Shift + Enter”输入代码时,条件将仅限于A2,这是我手动输入的单元格地址。 Is there anyway to check for every single cell without having to drag down WITHOUT USING VBA? 无论如何,是否无需使用VBA即可向下拖动而检查每个单元格? I know using VBA would make it a lot easier, but I just want to understand the basics of Excel further. 我知道使用VBA会使它容易得多,但我只是想进一步了解Excel的基础。

Try, 尝试,

=iferror(index(a:a, aggregate(15, 7, row(a:a)/(left(a$1:index(a:a, match("zzz", a:a)))="a"), row(1:1))), text(,))
'with 9 length criteria
=iferror(index(a:a, aggregate(15, 7, row(a:a)/((left(a$1:index(a:a, match("zzz", a:a)))="a")*(len(a$1:index(a:a, match("zzz", a:a)))=9)), row(1:1))), text(,))

Fill down as necessary. 根据需要填写。

If you only want the single left-most character from a string of text, you do not have to supply a 1; 如果只需要文本字符串中最左边的单个字符,则不必提供1;否则,不必输入1。 you can omit the number of characters argument. 您可以省略字符数参数。

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

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