I have a column containing US state abbreviations. I'd like to have an array of all 50 states:
const states = ['DE','AK','TX','CA' .........]
that the value of each cell in the column is compared against. If its not one of the states I'd like to format it red.
I've looked at conditional formatting ( https://developers.google.com/apps-script/reference/spreadsheet/conditional-format-rule-builder#whenTextDoesNotContain(String) ) where they have sample code like:
var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
.whenTextDoesNotContain("hello")
.setBackground("#FF0000")
.setRanges([range])
.build();
var rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);
Is there a conditional rule that would allow (in pseudocode):
.whenTextDoesNotContain(states)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.