0

My Google Sheet Conditional Formatting rules are full of Strings, like =INDIRECT("Settings!D18").

If I rearrange things on my Settings sheet and D18 becomes X45, is there a way for me to do a global Search/ Replace to reflect that?

2

1 Answer 1

1

You could do this with Google Apps Script to bulk edit the conditional formatting rules programmatically

For this, use the ConditionalFormatRuleBuilder and the withCriteria() builder.

Sample:

function bulkUpdateConditionalFormatting(){ var sheet = SpreadsheetApp.getActiveSheet(); var rules = sheet.getConditionalFormatRules(); var newRules = []; var newCriteriaValues rules.forEach(function(rule){ var booleanCondition = rule.getBooleanCondition(); Logger.log(booleanCondition.getCriteriaValues()); if (booleanCondition != null && booleanCondition.getCriteriaType() == 'CUSTOM_FORMULA') { var values = booleanCondition.getCriteriaValues() values.forEach(function(value,i){values[i] = value.replace("D18", "D45")}); var newRule = SpreadsheetApp.newConditionalFormatRule() .withCriteria(booleanCondition.getCriteriaType(), values) .setBackground(booleanCondition.getBackground()) .setRanges(rule.getRanges()) .build(); newRules.push(newRule); } }) sheet.setConditionalFormatRules(newRules); } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.