简体   繁体   English

Excel计数带有“ an”的列中的单元格数,直到下一个单元格为非“ an”

[英]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.

相关问题 在Excel中,如何计算空白单元格的数量,直到下一个非空白单元格 - In Excel, How do I count the number of blank cells until the next non-blank cell Excel - 计算列中的空单元格,直到找到非空单元格报告然后继续向下列直到找到下一个非空单元格 - Excel - Count Empty Cells in a Column until a Non Empty Cell is Found Report then Continue down column till next non empty cell is found 计算最后一个单元格与下一个非空白单元格之间的行中的空白单元格数 - Count number of blank cells in row between last cell and next non-blank cell Excel 计数空白单元格,直到找到下一个空白单元格 - Excel count blank cells until next blank cells is found 计算在下一个非空白单元格处停止的单元格上方的空白单元格 - Count blank cells above a cell stopping at the next non blank cell Excel:计算一列中的单元格数量,直到它们的总和大于设置值 - Excel: count the number of cells in a column until their sum is greater than a set value Excel-对列求和,直到到达非数字的单元格 - Excel - Sum column until it reaches a cell that is not a number MS Excel:计算一列中与其左侧的单元格编号相同的单元格的数量 - MS Excel: Count the number of cells in a column that have the same number as the cell to the left of it Excel计数A列中的单元格小于B列中的相应单元格的范围内的次数 - Excel Count number of times in range that cells in column A are less than corresponding cell in column B Excel宏可对已排序的列中的相同单元格进行递增编号,并在单元格内容更改时将计数重置为1 - Excel macro to incrementally number identical cells in a sorted column, resetting count to 1 when cell content changes
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM