I'm trying to use a function in sheets that will count the number of cells that correspond to the parameter colorref. The issue I'm having is that I need to run this function on a range that has a conditional color background set. Which is returning every cell as white.
Any help is super helpful! Thanks.
For example:
countonBG("E:E", "V2")
V2 = '#FFFF' // white
conditional: if E:E = U:U then E:E background color = 'yellow'
return remaining white cells
function countonBG(range,colorref) {
var sheet = SpreadsheetApp.getActiveSheet();
var color = sheet.getRange(colorref).getBackground();
var range = sheet.getRange(range);
var rangeVal = range.getValues();
var count = 0;
var allColors = range.getBackgrounds();
for (var i = 0; i < rangeVal.length; i++) {
for (var j = 0; j < allColors[0].length; j++) {
if (allColors[i][j] == color) count += 1;
};
};
return count
}