0
votes

I'm trying to copy the values from one sheet : https://docs.google.com/spreadsheets/d/1UDWk1xGnnL6qH_l5vo2MMwGH8wyXu0D9DCQMmZEKUJ0/edit#gid=0

To another : https://docs.google.com/spreadsheets/d/1dWYj2W3gTDnNuqgX9O9RS0WWL02aDUQAVl1HJ5jTtvE/edit#gid=595677628

I tried the code there, but when I run it, nothing happens. I'm new to programmation, so maybe it's something vary basic.

function myFunction() {
function transferList() {
  var sourceSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("OVERVIEW");
  var sourceData = sourceSheet.getDataRange().getValues();
  var targetSS = SpreadsheetApp.openById("1dWYj2W3gTDnNuqgX9O9RS0WWL02aDUQAVl1HJ5jTtvE").getSheetByName("RAWDATA");
  var targetRangeTop = targetSS.getLastRow();
  targetSS.getRange(targetRangeTop+1,1,sourceData.length,sourceData[0].length).setValues(sourceData);
}
}

I would like the values to be copied at the last available row...

1
Why do you have a function defined within a function - this isn't required at all to achieve your goal.ross
wow... thanks, see I'm a real newb and it worked !Guillaume Poulin

1 Answers

0
votes
function transferList() {
  var sourceSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("OVERVIEW");
  var sourceData = sourceSheet.getDataRange().getValues();
  var targetSS = SpreadsheetApp.openById("1dWYj2W3gTDnNuqgX9O9RS0WWL02aDUQAVl1HJ5jTtvE").getSheetByName("RAWDATA");
  var targetRangeTop = targetSS.getLastRow();
  targetSS.getRange(targetRangeTop+1,1,sourceData.length,sourceData[0].length).setValues(sourceData);
}