Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google apps script 调整脚本以设置IF公式_Google Apps Script_Google Sheets - Fatal编程技术网

Google apps script 调整脚本以设置IF公式

Google apps script 调整脚本以设置IF公式,google-apps-script,google-sheets,Google Apps Script,Google Sheets,我在修改脚本设置公式时遇到了一些困难,请提供帮助 我正在使用的当前脚本,它设置了一个简单的公式,从P1开始,然后p列中的每26行都可以,但是我想更改simple=AVL!公式,转换为IF公式。目前设置的公式非常简单。例如,下面是前三个公式集,脚本在P1、P27和P53中设置了它们。以此类推,每26行到第5175页 =AVL!BA3 =AVL!BA4 =AVL!BA5 Etc down to... =AVL!BA5175 这是剧本,没关系 function setFormu

我在修改脚本设置公式时遇到了一些困难,请提供帮助

我正在使用的当前脚本,它设置了一个简单的公式,从P1开始,然后p列中的每26行都可以,但是我想更改simple=AVL!公式,转换为IF公式。目前设置的公式非常简单。例如,下面是前三个公式集,脚本在P1、P27和P53中设置了它们。以此类推,每26行到第5175页

=AVL!BA3
=AVL!BA4
=AVL!BA5
           Etc down to...
=AVL!BA5175
这是剧本,没关系

function setFormulas() {

  var sheet, startRow, i; 
  sheet = SpreadsheetApp.getActiveSheet();
  startRow = 1;
  i = 3;
  while(startRow < 5181) {
    sheet.getRange(startRow, 16).setFormula('=AVL!BA' + i);
    i++;
    startRow += 26;
  }
}
函数setFormulas(){
风险值表,startRow,i;
sheet=SpreadsheetApp.getActiveSheet();
startRow=1;
i=3;
而(startRow<5181){
sheet.getRange(startRow,16).setFormula('=AVL!BA'+i);
i++;
startRow+=26;
}
}
我想更改公式集以设置下面的IF公式

=IF(AVL!BA3<>"",AVL!BA3,"NO STAFF AVAILABLE!")
=IF(AVL!BA4<>"",AVL!BA4,"NO STAFF AVAILABLE!")
=IF(AVL!BA5<>"",AVL!BA5,"NO STAFF AVAILABLE!")
=IF(AVL!BA3“”,AVL!BA3,“无可用人员!”)
=如果(AVL!BA4“”,AVL!BA4,“无可用人员!”)
=如果(AVL!BA5“”,AVL!BA5,“无可用人员!”)
我现在已经尝试了很多不同的方法,但都没有成功,但我相信这并不难,只是我的大脑已经停滞了

有人能帮忙吗

提前谢谢


Matt

您只需将
setFormula
部分更改为:


sheet.getRange(startRow,16).setFormula('=IF(AVL!BA'+i+',AVL!BA'+i+',“无可用人员!”)

我刚刚更改的列中保留了相同的内容。它是这样工作的吗?太好了,谢谢你的帮助和教我一些新东西!