[英]Google Spreadsheet - Scripts, copy cell from one sheet to another sheet EVERYDAY at a specific time
I know i might be asking the same thing. 我知道我可能会问同样的事情。 But i tried the scripts in different answers (obviously changing the cell value) but my question is bit different.
但是我尝试了不同答案的脚本(显然改变了单元格的值),但是我的问题有点不同。
I need to make a script in Google Spreadsheet to copy cell from one sheet to another sheet (In the same document) EVERYDAY at a specific time. 我需要在Google Spreadsheet中创建一个脚本,以便每天在特定时间将单元格从一张工作表复制到另一张工作表(在同一文档中)。
I have attached images below showing the what cells to copy from and to. 我已在下面附上图像,显示要复制和复制的单元格。 Some cells need a SUM formula before copying.
某些单元格在复制之前需要SUM公式。
I have also shared the copy of google sheet for convenience. 为了方便起见,我还共享了Google工作表的副本。 https://docs.google.com/spreadsheet/ccc?key=0AlVSjrM0ckyLdEtiLVNuOVpwQ3BGdUgwU0VpcldKaFE&usp=sharing
https://docs.google.com/spreadsheet/ccc?key=0AlVSjrM0ckyLdEtiLVNuOVpwQ3BGdUgwU0VpcldKaFE&usp=sharing
Images: Sheet1 and Sheet2 http://i59.tinypic.com/23jsu9x.jpg 图片:Sheet1和Sheet2 http://i59.tinypic.com/23jsu9x.jpg
You can update the fromTo
array to include more ranges. 您可以更新
fromTo
数组以包含更多范围。 Script is fairly self-explanatory. 脚本是不言自明的。 Set up trigger to run
backup
everyday. 设置触发器以每天运行
backup
。 You might want to change GMT
to your timezone. 您可能需要将
GMT
更改为您的时区。
function backup() {
var src = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Daily Report");
var dst = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Monthly Production Report");
var dstRow = getDstRow(dst);
var fromTo = [["B26", 2],
["C26", 3],
["B29:B31", 4],
["C29:C31", 5],
["B34", 6],
["C34", 7]];
for (var i=0; i<fromTo.length; i++) {
var r = fromTo[i];
dst.getRange(dstRow, r[1]).setValue(src.getRange(r[0]).getValues().reduce(sum, 0));
}
}
function getDstRow(dst) {
var today = Utilities.formatDate(new Date(), "GMT", "yyyy-MM-dd");
Logger.log(today);
for (var row=1; row<=dst.getLastRow(); row++) {
Logger.log(dst.getRange(row,1).getValue());
try {
var d = Utilities.formatDate(dst.getRange(row, 1).getValue(), "GMT", "yyyy-MM-dd");
if (d == today) {
return row;
}
} catch (err) {}
}
}
function sum(a,b) {
return a + b;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.