Home > Mobile >  Google Sheets script to copy a range to another sheet
Google Sheets script to copy a range to another sheet

Time:01-17

I am trying to cut and paste a range to another sheet to track the history of prices. I would like the range on "Logging" of B2:D2, B3:D3, and so on; to be copied over to "History" A3:C3, D3:F3, and so on.

So far I have come up with:

function moveValues () {
 var ss = SpreadsheetApp.getActiveSpreadsheet ();
 var source = ss.getRange("Logging!B2:D2");
 var destSheet = ss.getSheetByName("History");
 var destRange = destSheet.getRange(destSheet.getLastRow() 1,1);
 source.copyTo (destRange , {contentsOnly: true});
 source.clear ();
}

This will take the the data on the Logging sheet B2:D2 and move it to the History sheet A3:C3 but I cant figure out how to copy the remaining vertical data and turn it into a horizontal arrangement on the next sheet.

Thank you.

[1]: enter image description here

  •  Tags:  
  • Related