[英]Script to paste values from one workbook into the bottom of another - google sheets
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. 我已经将这些值粘贴到另一个工作簿中,但是它们是从第30行开始粘贴(然后向下工作),而不是在顶部(当前为第2行)标识表的末尾并从第3行开始粘贴。
Eventually 32 workbooks will be writing into this table so it's important they're able to identify the bottom. 最终,将有32个工作簿写入此表,因此它们能够识别底部很重要。
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);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.