6

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 ();
}
CRABOLO
  • 8,605
  • 39
  • 41
  • 68
user2579734
  • 63
  • 1
  • 1
  • 4

1 Answers1

13

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 ();
}
Mogsdad
  • 44,709
  • 21
  • 151
  • 275