Skip to content

Instantly share code, notes, and snippets.

@alexkingorg
Created February 7, 2014 17:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexkingorg/8868105 to your computer and use it in GitHub Desktop.
Save alexkingorg/8868105 to your computer and use it in GitHub Desktop.
Google Spreadsheet coloring code
function onEdit(e) {
setColors();
};
function setColors() {
var activeSheet = SpreadsheetApp.getActiveSheet();
var numRows = activeSheet.getMaxRows();
var numCols = activeSheet.getMaxColumns();
var row, cell, value;
// immediate rejections
for (var i = 1; i <= numRows; i++) {
row = activeSheet.getRange(i, 1, 1, numCols);
cell = activeSheet.getRange(i, 15);
value = cell.getValue();
if (value == ‘1’) {
row.setBackground(‘#999’);
}
else {
row.setBackground(‘#fff’);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment