I am trying to copy paste data from Google sheet1 to sheet2. I can copy data from specific cells but I am not able to paste data into specific sheet2 range. My function is automatically pasting data in last row of Column A,B, and C. I am using this Function below. Please any help guys.

function myFunction() {
  var ss = SpreadsheetApp.getActiveSpreadsheet ();
  var sourceSheet = ss.getSheetByName("Sheet1");
  var source = sourceSheet.getRange("E22:G22");

  var destSheet = ss.getSheetByName("Sheet2");
  var lastRow = destSheet.getLastRow();
  if (lastRow) destSheet.insertRowAfter(lastRow);
  source.copyTo(destSheet.getRange(lastRow + 1,1), {contentsOnly: true});

Your Answer

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

Browse other questions tagged or ask your own question.