I'm writing a script to take a range from one workbook (my active spreadsheet) and past it to another daily, so the values will aggregate to the bottom so not to overwrite anything from the previous days.
I've gotten the values to paste to the other workbook, but they're pasting starting at row 30 (and working down) instead of identifying the end of the table at the top (currently row 2) and starting on row 3.
Eventually 32 workbooks will be writing into this table so it's important they're able to identify the bottom.
Can you see what I have wrong here?
var inputRange = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet2").getRange("D13:I13");
var inputValues = inputRange.getValues();
var last = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1").getLastRow();
var tss = SpreadsheetApp.openById('1aNmmEVQbdWTcnbbrHb7ZWMtodPOHpQu-XNy55_ZZVLc');
var ts = tss.getSheetByName('Sheet1');
var outputRange = ts.getRange(last+1,1,1,6);
outputRange.setValues(inputValues);
saveAsCSV();
Try this:
function runOne() {
var ss=SpreadsheetApp.getActive();
var sh=ss.getSheetByName('Sheet2');
var rg=sh.getRange("D13:I13");
var vA=rg.getValues();
var tss=SpreadsheetApp.openById('1aNmmEVQbdWTcnbbrHb7ZWMtodPOHpQu-XNy55_ZZVLc');
var tsh=tss.getSheetByName('Sheet1');
var trg=tsh.getRange(tsh.getLastRow()+1,1,1,6);
trg.setValues(vA);
}