starting new thread on new problem I encountered. I have a code below which is intended to copy a range of cells into last empty row on another tab in a sheet. When running I got an error saying target range coordinates exceed sheet dimensions. Can you help me understand what I'm doing wrong here?

   function template(){
      const ss = SpreadsheetApp.getActiveSpreadsheet();
      const sourceSheet = ss.getSheetByName("Sprzedaż template");
      const numRows = sourceSheet.getRange("AB84").getValue();
      const sourceRange = sourceSheet.getRange("B84:Z84").offset(0,0,numRows);
      const destinationSheet = ss.getSheetByName("Sprzedaż");
      const lastRow = destinationSheet.getLastRow();
      sourceRange.copyTo(destinationSheet.getRange(lastRow+1,1),SpreadsheetApp.CopyPasteType.PASTE_VALUES, false);

1 Answer 1



  destinationSheet.insertRowsAfter(lastRow, numRows);

...before sourceRange.copyTo().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.