检查大写或小写字母的值-Google脚本

时间:2018-11-14 13:54:30

标签: google-sheets

我想检查A B和C列是否用“是”或“是”填充。

我有这段代码,这适用于大写的“是”

if([1,2,3].indexOf(e.range.getColumn()) > -1) {
    if (Col1 == "Yes" && Col2 == "Yes" && Col3 == "Yes") {Some action here}

但是当我向其中添加||(OR)时,代码将失败。

if([1,2,3].indexOf(e.range.getColumn()) > -1) {
    if ((Col1 == "Yes"||"yes") && (Col2 == "Yes"||"yes")  && (Col3 == "Yes"||"yes") ) {Some action here}

希望在这里寻求帮助;)

2 个答案:

答案 0 :(得分:0)

如果我了解要求,那么当前的方法可能会很麻烦。三个列的条件计数(不区分大小写)寻找“是”,然后根据结果为3而采取的进一步操作可能会更简单。

答案 1 :(得分:0)

您的OR语句不正确-您需要指定要再次检查的变量。例如:

if([1,2,3].indexOf(e.range.getColumn()) > -1) {
    if ((Col1 == "Yes" || Col1 == "yes") && (Col2 == "Yes" || Col2 == "yes")  && (Col3 == "Yes" || Col3 == "yes") ) {Some action here}