Skip to content

Instantly share code, notes, and snippets.

@ja6lee
ja6lee / Code.gs
Last active August 26, 2016 16:01
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');