Count rows with not empty value

后端 未结 13 2446
梦毁少年i
梦毁少年i 2020-12-13 08:04

In a Google Spreadsheet: How can I count the rows of a given area that have a value? All hints about this I found up to now lead to formulas that do count the rows which hav

13条回答
  •  暖寄归人
    2020-12-13 08:28

    You can define a custom function using Apps Script (Tools > Script editor) called for example numNonEmptyRows :

    function numNonEmptyRows(range) {
      Logger.log("inside");
      Logger.log(range);
      if (range && range.constructor === Array) {
        return range.map(function(a){return a.join('')}).filter(Boolean).length
      }
      else {
        return range ? 1 : 0;
      }
    }
    

    And then use it in a cell like this =numNonEmptyRows(A23:C25) to count the number of non empty rows in the range A23:C25;

提交回复
热议问题