Last active
February 28, 2018 17:53
-
-
Save nsfyn55/8f4fb827d44a60a1c9d6f57e180476d4 to your computer and use it in GitHub Desktop.
Highlight Rows Based on Column in Google Sheets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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