如果row
,我的代码可以移动col5=Published
。如果col5=Published
或Deleted
或Denied
function
可行,我想添加更多内容。我试过像它一样使用
var valueToWatch = ("Published","Deleted","Denied");
但它不起作用。 string
或Denied
Published
Deleted
var sheetNameToWatch = "Sheet1";
var columnNumberToWatch = 5; // column A = 1, B = 2, etc.
var valueToWatch = ("Published","Deleted","Denied");
var sheetNameToMoveTheRowTo = "Sheet2";
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getActiveCell();
if (sheet.getName() == sheetNameToWatch && range.getColumn() == columnNumberToWatch && range.getValue() == valueToWatch) {
var targetSheet = ss.getSheetByName(sheetNameToMoveTheRowTo);
var targetRange = targetSheet.getRange(targetSheet.getLastRow() + 1, 1);
sheet.getRange(range.getRow(), 1, 1, sheet.getLastColumn()).moveTo(targetRange);
sheet.deleteRow(range.getRow());
}
}
答案 0 :(得分:0)
尝试使用以下内容:
//var valueToWatch = ("Published","Deleted","Denied");
var valueToWatch = ['Published', 'Deleted', 'Denied'];
...
if (... && valueToWatch.indexOf(range.getValue()) > -1 && ...) {
...
}
...
调整代码中所需的所有内容。