5
votes

I would like to modify the script shown below, so that if re-run, it does not overwrite pre-existing data, but instead writes the rows under it.

(I use the google spreadsheet)

moveValuesOnly fonction () {
var ss = SpreadsheetApp.getActiveSpreadsheet ();
var source = ss.getRange ("Sheet1 F1: H3 ');
source.copyTo (ss.getRange ("Feuil2 A1! '), {contentsOnly: true});
source.clear ();
}
1

1 Answers

11
votes

This version will find the first empty row in the destination sheet, and copy the source data so it starts there.

function moveValuesOnly () {
  var ss = SpreadsheetApp.getActiveSpreadsheet ();
  var source = ss.getRange ("Sheet1!F1:H3");
  var destSheet = ss.getSheetByName("Feuil2");
  // Déterminer l'emplacement de la première ligne vide.
  var destRange = destSheet.getRange(destSheet.getLastRow()+1,1);
  source.copyTo (destRange, {contentsOnly: true});
  source.clear ();
}