I am writing a script to conditionally format my spreadsheet, but I do not know how to create multiple conditions. I have tried several edits to fix my problem, which is that when I run this function, every blank cell in the column will turn red, or every cell that meets the conditions of formula2 will turn red. I want only the cells that both meet formula2 conditions and are blank to turn red.
When I use the notation .whenCellEmpty().whenFormulaSatisfied(formula2)... All of the cells that meet formula2 conditions turn red, even if they are not blank.
When I use the notation .whenFormulaSatisfied(formula2).whenCellEmpty()... All of the blank cells turn red, even when they don't meet formula2 conditions.
Is there a way to write both of these conditions into the same rule?
var range2a = sheet.getRange(3, 16, sheet.getLastRow()-2, 1);
var range2b = sheet.getRange(3, 17, sheet.getLastRow()-2, 1);
var formula2 = '=OR(D3:D="Sale Escrow", D3:D="Sold", D3:D="Subsequent
Issue")';
var rule2a = SpreadsheetApp.newConditionalFormatRule()
.whenCellEmpty().whenFormulaSatisfied(formula2)
.setBackground("#FF0000")
.setRanges([range2a])
.build();
var rules2a = sheet.getConditionalFormatRules();
rules2a.push(rule2a);
sheet.setConditionalFormatRules(rules2a);
var rule2b = SpreadsheetApp.newConditionalFormatRule()
.whenCellEmpty()
.setBackground("#FF0000")
.setRanges([range2b])
.build();
var rules2b = sheet.getConditionalFormatRules();
rules2b.push(rule2b);
sheet.setConditionalFormatRules(rules2b);