The condition you're using seems to have an issue because the output of currentRange
and currentRange.getValues()
doesn't match what the condition expects and that's why else
condition triggers instead.
If you check the value by using console
you will get the output of:
console.log(currentRange) = object
console.log(currentRange.getValues()) = undefined
Agreeing to @Martin using strings to retrieve the ranges
.
To make it work here's a modified version of your code:
function SUM_UNCOLORED_CELLS(...ranges) {
var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var rl = ss.getRangeList(ranges);
var bg = rl.getRanges().map(rg => rg.getBackgrounds());
return bg.flat(2).filter(c => c == "#ffffff").length;
}
To learn more about how to pass a range into a custom function in Google Spreadsheets, you can read this post: How to pass a range into a custom function in Google Spreadsheets?