google script conditional formatting

168 views Asked by At

I have put together a google spreadsheet that highlights the first four cells in a row if the value in cell 6 is within 3 days of the current date, but I cannot figure out how to add an if/and statement to exclude all entries that have "East" in row E.

This is the code that I have had success with, minus the exclusion of East not highlighting.

onEdit(e) {
if (e) { 
var ss = e.source.getActiveSheet();
var r = e.source.getActiveRange(); 
if (r.getRow() != 2 && ss.getName() == "Sheet1") {
Days_Remaining = ss.getRange(r.getRow(),6).getValue();
rowRange = ss.getRange(r.getRow(),1,1,4);
if (Days_Remaining < 3.8) {
rowRange.setBackgroundColor("#FF0000");
} else if (Days_Remaining == 'N/A') {
rowRange.setBackgroundColor("#ffffff");
} else if (Days_Remaining > 3.9) { 
rowRange.setBackgroundColor("#ffffff");

https://docs.google.com/spreadsheet/ccc?key=0AqtCuK7ex8ZNdGxKLUZpQnZ3UzRCV3VoclVDbFVqQnc#gid=0

1

There are 1 answers

0
Chris On

If you use the new Google Sheets, you can simplify by using Conditional Formatting

If not, you need to get the values in column 5 as well and add an IF block based on that. For example:

Follow_up = ss.getRange(r.getRow(),5).getValue();

And then, before you check Days_Remaining, you should add

If(Follow_up <> "East") {//rest of the checks here }