简体   繁体   中英

How to get the last filled row in a specific column of a Google Sheet?

I am trying to automatically fill in the last row of a Google Sheet into a range from C2:K{{last_row}} . However, I am not sure how to proceed given my following code:

var dataSpreadsheetUrl = "https://docs.google.com/spreadsheets/sjhsak"; 
//make sure this includes the '
var ss = SpreadsheetApp.openByUrl(dataSpreadsheetUrl);
var deck = SlidesApp.getActivePresentation();
var sheet = ss.getSheetByName('Form_Responses');
var values = sheet.getRange('C2:K{{last_row}}').getValues();

How would I do this?

I am not sure what is your goal, but you must be looking for this:

sheet.getRange(`C2:K${sheet.getLastRow()}`).getValues();

If you want to store values starting from the last row and first column you could do this:

sheet.getRange(sheet.getLastRow()+1,1,values.length,values[0].length).setValues(values);

References:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM