Looking for google-apps-script Answers? Try Ask4KnowledgeBase
Looking for google-apps-script Keywords? Try Ask4Keywords

google-apps-script Get the last row in a single column


Example

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;
    }
  }
}