在一张表中,添加自定义函数时一切正常,countCellsWithBackgroundColor计算单元格。而在第二个表中不起作用。显示在单元格中#ERROR。可能是什么问题呢?
function countCellsWithBackgroundColor(color, rangeSpecification) {
var sheet = SpreadsheetApp.getActiveSpreadsheet();
var range = sheet.getRange(rangeSpecification);
var x = 0;
for (var i = 1; i <= range.getNumRows(); i++) {
for (var j = 1; j <= range.getNumColumns(); j++) {
var cell = range.getCell(i, j);
if (cell.getBackgroundColor() == color)
x++;
}
}
return x;
}
该消息
#ERROR指示公式语法错误。最有可能的是,有必要考虑表中公式的编写,而不是脚本。尝试将分号作为参数分隔符
这取决于表的本地设置。