I have the following code in Google spreadsheet script.
function countTextColor(inputColor, inputRange) {
var inputRangeCells = SpreadsheetApp.getActiveSpreadsheet().getRange(inputRange);
return inputRangeCells.getFontColor();
}
If I execute it like this:
=countTextColor("A1:E1")
I get the color of the first cell in the range.
But my purpose is to loop through the range and count the font color (specifeid as an input parameter) of all the cells. Adding the following code seems not to work:
var count = 0;
for(var r = 0; r < inputRangeCells.length; r++) {
var inputCell = inputRangeCells[r];
if(inputCell.getFontColor() == inputColor) {
count++;
}
}
How to loop the range and get the color value of each cell?