简体   繁体   English

将一个工作簿中的值粘贴到另一个工作簿底部的脚本-Google表格

[英]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.

相关问题 Google 表格脚本 - 将粘贴值从一列复制到另一列 - Google sheets script - copy paste values from one column to another 将数据从一个 Google 工作表工作簿工作表复制到另一个工作簿 - Copy Data from One Google sheets Workbook Sheet to another Workbook 如何使用 Google Sheets Macros 从一张工作表复制值并将它们粘贴到另一张工作表中? - How to copy values from one sheet and paste them into another using Google Sheets Macros? Google表格:根据复选框从一张纸复制并粘贴到另一张纸 - Google Sheets: Copy and Paste from one sheet to another based on checkbox 谷歌脚本在编辑时将值从一列复制并粘贴到另一列 - Google Script to copy and paste values from one column to another upon edits Google脚本 - 将数据从一个工作簿复制到另一个工作簿 - importrange()替代方案 - Google Script - Copy Data from one Workbook To Another - importrange() Alternative Google 工作表脚本将数据集从一张工作表复制到另一张工作表的顶部(仅限值) - Google sheets script copy data sets from one sheet to another (values only) at the top of the sheet 如何使用Google表格脚本有效地将值和公式的范围从一列移动到另一列? - How can I effeciently move a range of values and formulas from one column to another using a google sheets script? Google 表格:提交按钮以将值从工作簿 A 传递到工作簿 B - Google Sheets: submit button to pass values from Workbook A to Workbook B 使用谷歌脚本从一个文件清除、复制和粘贴到另一个文件 - Clear, copy and paste from one file to another using google script
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM