title: Counting number of rows where two column requirements: String and Color
body: <p>This would have been easier if the COUNTIF function works with cell colors. I have two columns, one is text and one is just a cell colour. It only counts if the text in the first column matches the required colour (yellow in this case). </p>
  
  <pre><code>  //yellow AIMS is "#ffd966"
    // red to be raised is "#ff0000"
  
  function countCellBGColour(coc, rangeSpecification) {
  
    var color = "#ffd966";
    var sheet = SpreadsheetApp.getActiveSpreadsheet();
    var backGroundColors = sheet.getRange(rangeSpecification).getBackgrounds();
    var cocsheet = sheet.getRange("Sheet1!E:E");
  
    var x = 0;
  
    for (var i = 0; i &lt; backGroundColors.length; i++) {
      for (var j = 0; j &lt; backGroundColors[0].length; j++) {
  
        if(backGroundColors[i][j] == color &amp;&amp; cocsheet == coc)
           { x++ }
  
      }
    }
    return x;
  }
  </code></pre>