[英]Modify Code - Copy Certain Rows/Columns From one Spreadsheet to Another - Google Apps Script / Google Sheets
I would like to incorporate the action the SORT QUERY is doing (above .getRange line of code) in this script.我想在此脚本中合并 SORT QUERY 正在执行的操作(在 .getRange 代码行上方)。 So instead of copying A2:FI would get Column B, C, D, E copied from ONLINESendNewSkusToGID to RECTOONLINE.因此,不是复制 A2:FI,而是将 B、C、D、E 列从 ONLINESendNewSkusToGID 复制到 RECTOONLINE。
function CopyNewOnlineSkusFromCDSToGID() {
var spreadsheet = SpreadsheetApp.getActive();
spreadsheet.setActiveSheet(spreadsheet.getSheetByName('ONLINESendNewSkusToGID'), true);
//=SORT(QUERY(JIRA JQL QUERY!A2:F,"SELECT B, C, D, E",0))
spreadsheet.getRange('A2:F').activate();
var target = SpreadsheetApp.openById("");
var source_sheet = spreadsheet.getSheetByName("ONLINESendNewSkusToGID");
var target_sheet = target.getSheetByName("RECTOONLINE");
var source_range = source_sheet.getActiveRange();
var last_row = target_sheet.getLastRow();
var values = source_range.getValues();
target_sheet.getRange(last_row + 1, 1, values.length, values[0].length).setValues(values);
spreadsheet.getRange('A2').activate();
}
Thanks In Advance提前致谢
Here is the code snippet that copies the columns B to E from one sheet to other.这是将 B 列到 E 从一张工作表复制到另一张工作表的代码片段。 Let me know if this is what you meant to achieve with your question.让我知道这是否是您要通过问题实现的目标。
function CopyNewOnlineSkusFromCDSToGID() { // get spreadsheet var ss = SpreadsheetApp.getActiveSpreadsheet(); // get the two desired sheets var online = ss.getSheetByName("ONLINESendNewSkusToGID"); var rect = ss.getSheetByName("RECTOONLINE"); // get the values of the sheet we want to copy var values = online.getRange('B:E').getValues(); // set the values where we want to paste rect.getRange('B:E').setValues(values); }
For more info regarding how to get and set values check out here and here respectively.有关如何获取和设置值的更多信息,请分别查看此处和此处。 I hope this has helped you, let me know if you need anything else or if you did not understood something.我希望这对您有所帮助,如果您需要其他任何东西或者您不明白什么,请告诉我。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.