Creating a Google Script to copy values from a table to a different table on a seperate tab for Sheets

51 views Asked by At

I'm trying to create a script that allows you to copy the value of one table (that have a variety of formulae in it) into a different table automatically on Sunday nights.

You can find sheet I'm making here. The content of sheet1's table is what I want copied over to the table in sheet 3, under 'stock tea'.

1

There are 1 answers

0
Kishan On

Try the following code:

function myFunction() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet1 = ss.getSheetByName('sheet1');
  var sheet2 = ss.getSheetByName('sheet3');
  var range = sheet1.getRange("C4:F22");
  var values = range.getValues();
  range.copyTo(sheet2.getRange("C5"), SpreadsheetApp.CopyPasteType.PASTE_VALUES, false);
}