Skip to content

Instantly share code, notes, and snippets.

@ruzz311
Created September 6, 2018 18:16
Show Gist options
  • Save ruzz311/c9b1a583f3f71d6002fb181ac1ac540d to your computer and use it in GitHub Desktop.
Save ruzz311/c9b1a583f3f71d6002fb181ac1ac540d to your computer and use it in GitHub Desktop.
Google Sheets Macro Function - Highlight a max/min values in a column
/** @OnlyCurrentDoc */
function myFunction2() {
var spreadsheet = SpreadsheetApp.getActive();
var conditionalFormatRules = spreadsheet.getActiveSheet().getConditionalFormatRules();
conditionalFormatRules.push(SpreadsheetApp.newConditionalFormatRule()
.setRanges([spreadsheet.getActiveRange()])
.whenFormulaSatisfied('=$H:$H=max(H:H)')
.setBackground('#B7E1CD')
.build());
spreadsheet.getActiveSheet().setConditionalFormatRules(conditionalFormatRules);
conditionalFormatRules = spreadsheet.getActiveSheet().getConditionalFormatRules();
conditionalFormatRules.push(SpreadsheetApp.newConditionalFormatRule()
.setRanges([spreadsheet.getActiveRange()])
.whenFormulaSatisfied('=$H:$H=min(H:H)')
.setBackground('#F4C7C3')
.build());
spreadsheet.getActiveSheet().setConditionalFormatRules(conditionalFormatRules);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment