函数 countColoredCells(countRange,colorRef) { var activeRange = SpreadsheetApp.getActiveRange(); var activeSheet = SpreadsheetApp.getActiveSheet(); var activeformula = activeRange。
function countColoredCells(countRange, colorRef) {
var activeRange = SpreadsheetApp.getActiveRange();
var activeSheet = SpreadsheetApp.getActiveSheet();
var activeformula = activeRange.getformula();
var countRangeAddress = activeformula.match(/((.\*),/).pop().trim();
var backGrounds = activeSheet.getRange(countRangeAddress).getBackgrounds();
var colorRefAddress = activeformula.match(/,(.\*))/).pop().trim();
var BackGround = activeSheet.getRange(colorRefAddress).getBackground();
var countColorCells = 0;
for (var i = 0; i \< backGrounds.length; i++)
for (var k = 0; k < backGrounds[i].length; k++)
if (backGrounds[i][k] == BackGround)
countColorCells = countColorCells + 1;
return countColorCells;
};
尝试按颜色计数细胞,这是错误,请问如何解决这个问题