copy data from one sheet to another in google app script and append a row, one small issue

后端 未结 1 1418
北恋
北恋 2020-12-12 05:22

sure I had this down but just can\'t get it right. Had a script set up to get data from one sheet and put it into another one, which I have done but it leaves gaps when copy

相关标签:
1条回答
  • 2020-12-12 06:01

    You can copy whole range at once using copyTo, so your function could be rewritten as:

    function copyInfo() {
      var ss = SpreadsheetApp.getActiveSpreadsheet();
      var copySheet = ss.getSheetByName("Copy");
      var pasteSheet = ss.getSheetByName("Paste");
    
      // get source range
      var source = copySheet.getRange(2,2,12,2);
      // get destination range
      var destination = pasteSheet.getRange(pasteSheet.getLastRow()+1,2,12,2);
    
      // copy values to destination range
      source.copyTo(destination);
    
      // clear source values
      source.clearContent();
    }
    
    0 讨论(0)
提交回复
热议问题