[英]Google Sheets script to copy a range to another sheet
I am trying to cut and paste a range to another sheet to track the history of prices.我正在尝试将一个范围剪切并粘贴到另一张纸上以跟踪价格历史。 I would like the range on "Logging" of B2:D2, B3:D3, and so on;
我想要 B2:D2、B3:D3 等的“记录”范围; to be copied over to "History" A3:C3, D3:F3, and so on.
复制到“历史”A3:C3、D3:F3 等。
So far I have come up with:到目前为止,我想出了:
function moveValues () {
var ss = SpreadsheetApp.getActiveSpreadsheet ();
var source = ss.getRange("Logging!B2:D2");
var destSheet = ss.getSheetByName("History");
var destRange = destSheet.getRange(destSheet.getLastRow()+1,1);
source.copyTo (destRange , {contentsOnly: true});
source.clear ();
}
This will take the the data on the Logging sheet B2:D2 and move it to the History sheet A3:C3 but I cant figure out how to copy the remaining vertical data and turn it into a horizontal arrangement on the next sheet.这将获取日志记录表 B2:D2 上的数据并将其移动到历史记录表 A3:C3 但我不知道如何复制剩余的垂直数据并将其转换为下一张表上的水平排列。
Thank you.谢谢你。
It's going to the destination sheet to the lastrow plus one它将到达最后一行的目标表加一
function moveValues() {
var ss = SpreadsheetApp.getActive();
var ssh = ss.getRange("Sheet0!B2:D2");
var dsh = ss.getSheetByName("Sheet1");
var drg = dsh.getRange(dsh.getLastRow() + 1, 1);
ssh.copyTo(drg, { contentsOnly: true });
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.