I'm trying to do the following:
- Loop through column "A" in "Customer" and get corresponding sheet name.
- Get the sheet and copy all used range in sheet, e.g (A;B;C;etc) to the specific files referenced in column B.
Here's the code I've written so far:
function updatefile() {
var ss = SpreadsheetApp.getActive();
var sh = ss.getSheetByName('CUSTOMER')
var data = sh.getRange("A2:B12").getValues(); // get the range of non empty cells
for (var i = 1; i < data.length; i++) {
var source = ss.getSheetByName(data[i][0]);
var range = source.getRange('C3:M1003'); //assign the range you want to copy
var data = range.getValues();
var destination = SpreadsheetApp.openById(data[i][1]); // open the corresponding file by using the file id in the second column
var destbodya = destination.getSheetByName('UPDATE ON ORDERS');
destbodya.getRange(ts.getLastRow()+1, 1,49,7).setValues(data); //you will need to define the size of the copied data see getRange()
}
}
I finally got this to work after a lot of searching and trials. for those who comes by such challenges. Cheers