Change row color google spreadsheet script if column 17 is 1

Posted: April 23, 2013 in web

Change row color google spreadsheet script if column 17 is 1

function emasHighlight()
{
  var i, thisRow, thisValue;
  var sheet = SpreadsheetApp.getActiveSheet();
  var rows = sheet.getDataRange();
  var lastCol = rows.getNumColumns();
  var lastRow = rows.getNumRows();
  var aWhites = "white";
  var aYellows = "#00ffff";

  for (i = 1; i <= lastRow; i++)
  {
    thisRow = sheet.getRange(i, 1, 1, lastCol);
    thisValue = sheet.getRange(i, 17).getValue();
    if(i > 7){
      thisRow.setBackground((thisValue == 1)?aYellows:aWhites);
      
    }  
  }
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s