Determining the last row in a single column

前端 未结 19 1323
野性不改
野性不改 2020-11-22 10:46

I have a sheet with data in cols A through H.

I need to determine the last row in column A that contains data (it\'s all conti

19条回答
  •  醉酒成梦
    2020-11-22 11:10

    Here's an alternative way of solving this. It uses a while loop but takes into consideration empty gaps between rows.

    function getLastRow (column) {
      var iLastRow = ss.getActiveSheet().getMaxRows();
      var aValues = ss.getActiveSheet().getRange(column + ":" + column).getValues();
      var row = "";
      while(row == ""){
        row = aValues[iLastRow-1];
        iLastRow--;
      }
      return iLastRow;
    }
    

提交回复
热议问题