Skip to content

Instantly share code, notes, and snippets.

@ja6lee
Last active August 26, 2016 16:01
Show Gist options
  • Save ja6lee/05e6e5b2afcb6b7762fea133148ce1a5 to your computer and use it in GitHub Desktop.
Save ja6lee/05e6e5b2afcb6b7762fea133148ce1a5 to your computer and use it in GitHub Desktop.
Update the color of a cell in a Google Spreadsheet to match the color specified in the cell.
function onEdit(e) {
var range = SpreadsheetApp.getActiveSheet().getDataRange();
for (var j = range.getColumn(); j <= range.getLastColumn(); j++) {
for (var i = range.getRow(); i <= range.getLastRow(); i++) {
var cell = range.getCell(i, j);
var status = cell.getValue();
if (status[0] == '#') {
cell.setBackground(status);
} else {
cell.setBackground('#ffffff');
}
}
}
}
@mrhether
Copy link

this is cool man

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment