Answers for "google apps script getLastRow"

0

google apps script getLastRow

function lastRowForColumn(sheet, column){
  // Get the last row with data for the whole sheet.
  var numRows = sheet.getLastRow();
  
  // Get all data for the given column
  var data = sheet.getRange(1, column, numRows).getValues();
  
  // Iterate backwards and find first non empty cell
  for(var i = data.length - 1 ; i >= 0 ; i--){
    if (data[i][0] != null && data[i][0] != ""){
      return i + 1;
    }
  }
}
Posted by: Guest on February-15-2022

Code answers related to "google apps script getLastRow"

Browse Popular Code Answers by Language