0

I have set of data in Google Sheets that look like this:

WA102293 first Q example

Columns B and C are updated manually every day. On the other sheet, I'm trying to append the new data above. If updated, with the previous data, hopefully would look like this;

WA102293 second Q example

Anybody can help me?

1

Use the following script, making sure that the sheet names and the range are what you want. In the Script Editor (found under Tools) there is also Resources menu, using which you can add a trigger that will run the archive function once a day (for example, at night when the changes are already done).

function archive() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var source = ss.getSheetByName('Sheet1');      // name of source sheet
  var sourceRange = source.getRange('A2:C4');    // range to copy
  var destination = ss.getSheetByName('Sheet2'); // name of log sheet
  var lastRow = destination.getLastRow();
  destination.insertRowsAfter(lastRow, sourceRange.getHeight());
  sourceRange.copyTo(destination.getRange(lastRow + 1, 1));
}

The script copies the range A2:C4 of Sheet1 to the bottom of Sheet2.

  • Thanks for your answer. I got this error "Those rows are out of bounds. (line 7, file "Code")" when running the script. – Tonny Jan 22 '17 at 14:36

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.