Google Apps 脚本 setFormula 函数
Google Apps Script setFormula function
我在使用以下代码将 ArrayFormulas 插入 5 个特定单元格时遇到了一些 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 is not defined”错误消息,不明白为什么。
有人能帮忙吗?
提前感谢您的支持
这里是仍然有问题的调用函数:
function ManualSGAConso() {
Run_MID2019();
Run_2019SC();
Run_MID2020();
Run_AddForm();
}
首先,你在AddForm()函数中犯了一个小错误:
sh 应该是 sheet
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();
}
我在使用以下代码将 ArrayFormulas 插入 5 个特定单元格时遇到了一些 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 is not defined”错误消息,不明白为什么。
有人能帮忙吗?
提前感谢您的支持
这里是仍然有问题的调用函数:
function ManualSGAConso() {
Run_MID2019();
Run_2019SC();
Run_MID2020();
Run_AddForm();
}
首先,你在AddForm()函数中犯了一个小错误:
sh 应该是 sheet
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();
}