Reputation: 81
How to get the value of the last row number of an active sheet using google app script?
Upvotes: 1
Views: 53
Reputation: 15318
by .getMaxRows()
:
function nbRows(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
Logger.log(sheet.getMaxRows());
}
Upvotes: 1
Reputation: 81
Based from answer https://stackoverflow.com/a/9102463/1677912
function getLastSheetRowByColumnArray() {
var column = sheet.getRange('A:A');
var values = column.getValues(); // get all data in one call
var ct = 0;
while ( values[ct] && values[ct][0] == "" || values[ct] && values[ct][0] != "" ) {
ct++;
}
return (ct);
}
Upvotes: 0