Script to append range of data in Google Sheets

前端 未结 1 1609
隐瞒了意图╮
隐瞒了意图╮ 2021-01-07 03:44

I have a script that will copy and send a range of data to another sheet. I want to add another part to the script, that will do the same function but append the data to a n

相关标签:
1条回答
  • 2021-01-07 04:34

    yes, there is. You can use getLastRow().

    So your code would look like this:

    function appendToRecords() {
      var ss = SpreadsheetApp.getActiveSpreadsheet();
      var reportSheet = ss.getSheetByName("Report");
      var recordsSheet = ss.getSheetByName("Records")
      var reportData = reportSheet.getRange("L1:AC1")
                                  .getValues();
      var lastRow = recordsSheet.getLastRow();
      //copy data
      recordsSheet.getRange(lastRow + 1, 12, 1, 18)
                  .setValues(reportData);
    
    }
    
    0 讨论(0)
提交回复
热议问题