![](/img/trans.png)
[英]Google Sheets: Move a row of data to another sheet based on cell value
[英]How to move a row from one google spreadsheet to another based on a value in a cell?
我的脚本应该根据单元格中的值将一行从一个Google电子表格移动到另一行。 它没有做到这一点,我认为这是由于onEdit()函数,但无法弄清楚。 我在同一电子表格中找到了针对不同工作表的解决方案,但在不同电子表格中却找不到。 我的代码如下。
function onEdit(e) {
var sss = SpreadsheetApp.getActiveSpreadsheet();
var ss = e.source.getActiveSheet();
var r = e.source.getActiveRange();
if(s.getName() == "source_sheet" && r.getColumn() == 7 && r.getValue() == "Pavlovo"){
//Get full range of data
var SRange = ss.getRange(1, 3, 1, 5);
//get A1 notation identifying the range
var A1Range = SRange.getA1Notation();
//get the data values in range
var SData = SRange.getValues();
// tss = target spreadsheet
var tss = SpreadsheetApp.openById('1_t7BDCWgHJDip_cndzVashxLDQ_pVS6obi3I9TB_EJI');
var ts = tss.getSheetByName('Vitosha'); // ts = target sheet
//set the target range to the values of the source data
ts.getRange(A1Range).setValues(SData);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.