我在使用以下代码在 5 个特定单元格中插入 ArrayFormulas 时遇到了 Googles Apps 脚本的一些问题:
function AddForm() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
const sh=ss.getSheetByName('sheetname');
var cell = sheet.getRange("Z2");
cell.setFormula('=iferror(arrayformula(vlookup(J2:J,othersheetname!$L:$M,2,false)),"")');
var cell = sheet.getRange("AA2");
cell.setFormula('=iferror(arrayformula(vlookup(K2:K,othersheetname!$P:$Q,2,false)),"")');
var cell = sheet.getRange("AB2");
cell.setFormula('=iferror(arrayformula(vlookup(K2:K,othersheetname!$P:$Q,2,false)),"")');
}
我收到“ReferenceError: Run_AddForm 未定义”错误消息,不明白为什么。
请问有人可以帮忙吗?
预先感谢您的支持
这是仍然存在问题的调用函数:
function ManualSGAConso() {
Run_MID2019();
Run_2019SC();
Run_MID2020();
Run_AddForm();
}
首先,你在 AddForm() 函数中犯了一个小错误:
sh应该是表
function AddForm() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
const sheet=ss.getSheetByName('sheetname');
var cell = sheet.getRange("Z2");
cell.setFormula('=iferror(arrayformula(vlookup(J2:J,othersheetname!$L:$M,2,false)),"")');
var cell = sheet.getRange("AA2");
cell.setFormula('=iferror(arrayformula(vlookup(K2:K,othersheetname!$P:$Q,2,false)),"")');
var cell = sheet.getRange("AB2");
cell.setFormula('=iferror(arrayformula(vlookup(K2:K,othersheetname!$P:$Q,2,false)),"")');
}
由于您收到的错误消息正在寻找 Run_AddForm() 函数,请尝试将Run_AddForm()替换为AddForm():
function ManualSGAConso() {
Run_MID2019();
Run_2019SC();
Run_MID2020();
AddForm();
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句