[英]Excel count number of cells in column with “an” until next cell is non“an”
I would like to count the number of cells in column with "an", where the counting starts at a given row and counts go down to count the number of cells with "an" until a non-"an" cell is found? 我想用“ an”计数列中的单元格数量,其中从给定的行开始计数,然后递减计数以“ an”计数,直到找到非“ an”单元格?
For example 例如
Column A
opp
an
an
an
an
opp
I would like to calculate how many cell with "an" until the next non an cell. 我想计算直到下一个非单元格中带有“一个”的单元格。 For this example answer will be 4.
对于此示例,答案将为4。
Another example 另一个例子
Column B:
an
an
opp
an
an
an
The answer will be 2. 答案将是2。
You can perhaps try the formula: 您也许可以尝试以下公式:
=SUM(MATCH(0,IF(OFFSET(A1:A7,MATCH("an",A1:A7,0)-1,0)="an",1,0),0))-1
Entered as an array formula using Ctrl + Shift + Enter 使用Ctrl + Shift + Enter输入为数组公式
Where A1:A7 is the range. 其中A1:A7是范围。 Change it accordingly.
相应地更改它。
EDIT: To count from the bottom, maybe this: 编辑:从底部数,也许这:
=COUNTIF(OFFSET(C1:C9,MATCH(2,IF(OFFSET(C1,0,0,MATCH(2,IF(C1:C9<>"an",NA(),1)))="an",NA(),1)),0),"an")
Also entered as an array formula using Ctrl + Shift + Enter 也可以使用Ctrl + Shift + Enter输入为数组公式
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.