如果声明没有决定谷歌脚本

时间:2018-02-20 21:38:52

标签: javascript if-statement google-apps-script

我的If声明如果没有决定“rb”是否在设置的水平单元格中

我知道这个脚本非常粗糙,并且有更多方法可以进行这种类型的查找,但这是我第一次编码。如果有人可以帮助我的代码,甚至建议更好的方法来做这个我会做研究,真的很感激

{
function sortAndSeperate() {
 var i = 3;
 var days = 11
 var d =SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Coming Up work").getRange(2, 11);
 var sheet1 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Coming Up work");
 var worker = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Reuben");
 var rangeMonday =sheet1.getRange(i,1,1,10)
 //var rangeTuesday=sheet1.getRange(row, column, numRows, numColumns)
 var copyrange = worker.getRange(i - 1, 1, 1, 10)

 
 
 if (rangeMonday = "rb") {
 var paste =SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Coming Up work").getRange(i,1,1,10).copyTo(copyrange)
 var dateis = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Coming Up work").getRange(2 , days )
 var paste2 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Reuben").getRange(i - 1,5)
 var paste3 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Reuben").getRange(i - 1,6)
 dateis.copyTo(paste2)
 dateis.copyTo(paste3)
 }
  else {
   Logger.log('It is finished.');
 }

2 个答案:

答案 0 :(得分:0)

您需要一个双重或三等号,即=====

 if (rangeMonday === "rb") {
     var paste = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Coming Up work").getRange(i, 1, 1, 10).copyTo(copyrange)
     var dateis = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Coming Up work").getRange(2, days)
     var paste2 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Reuben").getRange(i - 1, 5)
     var paste3 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Reuben").getRange(i - 1, 6)
     dateis.copyTo(paste2)
     dateis.copyTo(paste3)
 } else {
     Logger.log('It is finished.');
 }

请参阅Comparison Operators

答案 1 :(得分:0)

if(x ==。Single =赋值不比较