Skip to content

Instantly share code, notes, and snippets.

@nsfyn55
Last active February 28, 2018 17:53
Show Gist options
  • Save nsfyn55/8f4fb827d44a60a1c9d6f57e180476d4 to your computer and use it in GitHub Desktop.
Save nsfyn55/8f4fb827d44a60a1c9d6f57e180476d4 to your computer and use it in GitHub Desktop.
Highlight Rows Based on Column in Google Sheets
function onEdit(e){
// Set a comment on the edited cell to indicate when it was changed.
var sheet = SpreadsheetApp.getActiveSheet();
statusColumn = 4;
if (sheet.getActiveCell().getColumn() == statusColumn) {
cell = sheet.getActiveCell();
column = cell.getColumn();
var row = sheet.getActiveRange().getRow();
var cellValue = cell.getValue();
var colLimit = 50
switch (cellValue) {
case "Open":
color = "#fff2cc";
break;
case "Closed":
color = "#d9ead3";
break;
case "In Progress":
color = "#fce5cd";
break;
case "Blocked":
color = "#cfe2f3";
break;
default:
break;
}
sheet.getRange(row, 1, 1, colLimit).setBackgroundColor(color);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment