Created
October 20, 2022 12:47
-
-
Save albertopasqualetto/9fbec183726e0b7a705fdf02a07a630d to your computer and use it in GitHub Desktop.
Copy conditional formatting rule to all the Google sheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** @OnlyCurrentDoc */ | |
function copyMyConditionalFormatting() { | |
var spreadsheet = SpreadsheetApp.getActive(); | |
var base_range = spreadsheet.getRange("B2:X2"); //Starting range | |
var conditionalFormatRules = spreadsheet.getActiveSheet().getConditionalFormatRules(); | |
for (var i=1; i<=1001-3; i++){ //Which columns | |
var new_rule = conditionalFormatRules[0].copy //Copy first rule to all sheet | |
.setRanges([base_range.offset(i, 0)]) //column offset | |
.build(); | |
conditionalFormatRules.push(new_rule); | |
} | |
spreadsheet.getActiveSheet().setConditionalFormatRules(conditionalFormatRules); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment