最終行・列を取得する

最終行を取得する

SHEET.getLastRow();

連続するデータの最終行を取得する

SHEET.getRange(1, 1).getNextDataCell(SpreadsheetApp.Direction.DOWN).getRow();