我正在研究一个功能
- 逐行浏览 Google 工作表中的指定列(在脚本中将 H 列表示为 value[7])。
- 根据 value[7] 列中具有特定值(“YES”)的单元格,它将选择整行。
- 然后它将所选行(全部)复制到同一文档中的单独工作表中。
这是我到目前为止所得到的:
function moveRowsBasedOnCellValue(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
var master = ss.getSheetByName('Main');
var values = master.getDataRange().getValues(); //selects all values in a sheet
values.forEach(function(value){
//if cell in the column H equals YES execute the script
if (value[7] == "YES"){
//variable to select all columns in the source sheet that aren't blank
var colWidth = master.getMaxColumns();
//variable containing the target sheet
var destinationYeses = ss.getSheetByName("Yeses");
//select first empty row in the destination sheet
var destinationYesesRange = destinationYeses.getRange(destinationYeses.getLastRow()+1,1);
//copy the relevant row into the sheet
master.getRange(value,1, 1, colWidth).copyTo(destinationYesesRange);
}});
}
该脚本执行良好,直到脚本的最后一行:
master.getRange(value,1, 1, colWidth).copyTo(destinationYesesRange);
错误指出:
Cannot convert [here the Logger error provides a list of all values in a row separated by a comma] to (class).
关于我可能做错了什么的任何想法?