title: Change cell background color onEdit based on value
body: <p>How can I change the cell background color based on the cell's content in an <code>onEdit()</code> function?</p>
  
  <p>I've had many versions of code that I tested for this - some working almost right, some not working at all.
  But I have yet to get this to work the way I need it to.</p>
  
  <p>Please forgive the lack of elegance in the way that this is written, but I actually need to keep the code as straightforward as possible since there will be many cell changes, many conditionals, and many differing numbers of cells that will be changed depending on what gets changed on the worksheet.</p>
  
  <p>Ok, so here goes...</p>
  
  <pre><code>function onEdit(event)
  {
   var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet2");   
   var changedCell= event.source.getActiveRange().getA1Notation();
  
   if (changedCell == 'B3') {
   var c = ss.getRange("B3").getValue();
    if (c &lt; 2); {
    ss.getRange("B3").setBackgroundColor('#ff0000');  
    ss.getRange("B12").setBackgroundColor('#ff0000'); 
    }
    if (c &gt; 1); {
    ss.getRange("B3").setBackgroundColor('#000000');  
    ss.getRange("B12").setBackgroundColor('#000000'); 
    }
   }
  }
  </code></pre>