0
votes

How do I copy one a Range from CopyFromMe tab, and paste to end of PasteAtEndOfMe tab in Google Sheets?

The function below has ERROR "The coordinates of the target range are outside the dimensions of the sheet." (unless I take out the +1)... but it does not paste anything. I've also tried other variations like ,{contentsOnly:true});

   function CopyInfoToEndOfDifferentTab() {
      var ss = SpreadsheetApp.getActiveSpreadsheet();
      var copySheet = ss.getSheetByName('CopyFromMe');
      var pasteSheet = ss.getSheetByName('PasteAtEndOfMe');

      var source = copySheet.getRange('K8:P17')


    var destination = pasteSheet.getRange(pasteSheet.getLastRow()+1,1,source.getHeight(), source.getWidth());


    source.copyTo(destination);  

    }

I've tried this. Also tried this, from another thread... but still does nothing. Result is blank on PasteAtEndOfMe tab.

    function recordHistory() {
  var ss = SpreadsheetApp.getActive();
  var sheet = ss.getSheetByName("CopyFromMe");
  var source = sheet.getRange("K8:P17");
  var values = source.getValues();
  var sheet2 = ss.getSheetByName("PasteAtEndOfMe");
  values [0][0] = new Date();
  sheet2.getRange(sheet2.getLastRow()+1,1,values.length,values[0].length).setValues(values);
}

References:

Google Sheets Script - Copying data range from one sheet to another - whole range not copying

1
Please provide a copy of the dataset.Neven Subotic
Well I feel silly... there were some formulas with content in it not visible on the sheet, rendering to look like empty cells. So, it was adding after row 1000B D

1 Answers

0
votes

Make sure there is no data in any of the columns, even if invisible formula that renders nothing (like an if statement that renders “”)

This was adding content past Row 1000 so looked like it wasn’t working on the visible test rows