尝试在下面运行脚本时遇到以上消息。
我的目标是一旦用户从L列的下拉列表中选择了“批准”,就将“已验证”工作表中的每个新行复制到下一个工作表“处理中”。还要从Source(已验证)电子表格中删除一旦移至“处理中”
function copyrange() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName('VALIDATED'); //source sheet
var testrange = sheet.getRange('L:L'); //range to check
var testvalue = (testrange.getValues());
var csh = ss.getSheetByName('PROCESSING'); //destination sheet
var data = [];
var j =[];
//Condition check in L:L; If true copy the same row to data array
for (i=0; i<testvalue.length;i++) {
if ( testvalue[i] == 'Approved') {
data.push.apply(data,sheet.getRange(i+1,1,1,25).getValues());
//Copy matched ROW numbers to j
j.push(i);
}
}
//Copy data array to destination sheet
csh.getRange(csh.getLastRow()+1,1,data.length,data[0].length).setValues(data);
//Delete matched rows in the source sheet
for (i=0;i<j.length;i++){
var k = j[i]+1;
sheet.deleteRow(k);
//Alter j to account for deleted rows
if (!(i == j.length-1)) {
j[i+1] = j[i+1]-i-1;
}
}
}