简体   繁体   English

计算特定范围/列Excel中的非空行

[英]Count non blank rows in a certain range/column Excel

I want to count empty (or non-blank) rows in a given column (or range). 我想计算给定列(或范围)中的空(或非空)行。 Example: I have a column which is spaning over 4 cells width, and each cell has either a single ''x'' or is empty. 示例:我有一个超过4个单元格宽度的列,每个单元格都有一个“x”或空。 There is up to 100 rows under this column. 此列下最多有100行。 Here's a picture to clarify: 这是一张图片来澄清:

剪辑excel表

The COUNTA() function will do that for you. COUNTA()函数将为您执行此操作。 For example: 例如:

=COUNTA(A1:A100)

Will return the number of non-blank cells in the range A1:A100 将返回A1:A100范围内的非空单元格数

Use a new column to get the number of blank cells in each row, then count the number of row in this column which are equal to 4. 使用新列获取每行中的空白单元格数,然后计算此列中等于4的行数。

Or, more simply, write =QUOTIENT(COUNTBLANK(B2:E2);4) in F2, pull the cell down, then write =SUM(F2:F101) in G2. 或者,更简单地说,在F2中写入=QUOTIENT(COUNTBLANK(B2:E2);4) ,向下拉单元格,然后在G2中写入=SUM(F2:F101)

If there is exactly 4 blank cell in a row, the F cell will have a value of 1 and the sum will just add all of these 1 to get the number of empty rows. 如果一行中恰好有4个空白单元格,则F单元格的值为1,并且总和将只添加所有这些1以获得空行数。

You can use array formula. 您可以使用数组公式。 For example, to count the first 10 rows starting from row 2. 例如,要计算从第2行开始的前10行。

=SUM((COUNTBLANK(OFFSET(B2,ROW(1:10)-1,0,1,4))=4)*1)

在此输入图像描述

To count the first 100 rows: 计算前100行:

=SUM((COUNTBLANK(OFFSET(B2,ROW(1:100)-1,0,1,4))=4)*1)

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

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