简体   繁体   English

用于将范围复制到另一张工作表的 Google 表格脚本

[英]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 behaving properly它的行为正常

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.

相关问题 如何将一张工作表的值复制到另一张工作表Google工作表脚本 - How to copy the value of one sheet to another sheet Google sheets Script 用于在最后一条记录后复制并粘贴到另一个工作表的 Google Sheets 脚本 - Google Sheets script to copy and paste in another sheet after the last record 通过for循环谷歌表格脚本将行复制到另一张表格 - Copy row to another sheet via for loop google sheets script Google Script:将值从一张纸复制到另一张纸以确定范围 - Google Script: copy values from one sheet to another determining the range 谷歌表格脚本:获取表格命名范围已打开 - Google Sheets Script: Get Sheet a Named Range is On Google 工作表将整个工作表复制到另一个工作表 - Google sheets copy whole sheet to another 将数据复制到另一张Google表格中 - Copy data to another sheet Google Sheets Google 工作表脚本将数据集从一张工作表复制到另一张工作表的顶部(仅限值) - Google sheets script copy data sets from one sheet to another (values only) at the top of the sheet Google Sheets Script - 将数据范围从一张表复制到另一张表 - 整个范围不复制 - Google Sheets Script - Copying data range from one sheet to another - whole range not copying 复制一个范围并仅将具有值和图像的行粘贴到另一个工作表中下一个空白行的谷歌工作表中? - Copy a range and paste only rows with values & images into another sheet at the next blank row in the google sheets?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM