How can I count the rows with data in an Excel sheet?

后端 未结 6 2084
情书的邮戳
情书的邮戳 2021-01-04 08:24

I am trying to count the number of rows in a spreadsheet which contain at least one non-blank value over a few columns: i.e.

row 1 has a text value in column         


        
6条回答
  •  情歌与酒
    2021-01-04 08:55

    If you want a simple one liner that will do it all for you (assuming by no value you mean a blank cell):

    =(ROWS(A:A) + ROWS(B:B) + ROWS(C:C)) - COUNTIF(A:C, "")
    

    If by no value you mean the cell contains a 0

    =(ROWS(A:A) + ROWS(B:B) + ROWS(C:C)) - COUNTIF(A:C, 0)
    

    The formula works by first summing up all the rows that are in columns A, B, and C (if you need to count more rows, just increase the columns in the range. E.g. ROWS(A:A) + ROWS(B:B) + ROWS(C:C) + ROWS(D:D) + ... + ROWS(Z:Z)).

    Then the formula counts the number of values in the same range that are blank (or 0 in the second example).

    Last, the formula subtracts the total number of cells with no value from the total number of rows. This leaves you with the number of cells in each row that contain a value

提交回复
热议问题