I am currently working on a conditional formatting color scale script for Sheets and I am stuck at selecting the ranges to be colored. It works fine if I only select one arbitrary large range, but not if I am highlighting two or more separate ranges on one sheet. In this case, my function is only applied to the range selected at last. Here is a simple example of a function: It takes the active range and sets the colors of the cells red.
function red() {
var curRange = SpreadsheetApp.getActiveRange();
curRange.setBackgroundColor("#FF0000");
}
How can this be applied to all selected ranges, when multiple ranges or separate? Something like getActiveRanges(). Thanks