title: Programmatically test if a Google Sheet cell is in a named range
body: <p>I'm writing a Google Sheets <code>onEdit()</code> trigger and it only needs to do something if any of the edited cells are in a named range on the spreadsheet.</p>
  
  <p>I have this:</p>
  
  <pre><code>function onEdit(e) {
    var editRange = e.range;
  
    var numRows = editRange.getNumRows();
    var numCols = editRange.getNumColumns();
  
    for (var i = 1; i &lt;= numRows; i++) {
      for (var j = 1; j &lt;= numCols; j++) {
        var cell = editRange.getCell(i,j);
  
        if (isInRange(cell, myNamedRange)) {
           /* Do something clever */
        }
      }
    }
  }
  </code></pre>
  
  <p>But I'm having trouble writing the <code>isInRange()</code> function. It feels like it should be a built-in spreadsheet function, but I can't find anything that looks likely.</p>
  
  <p><strong>Update:</strong> It struck me overnight that there might be an easier approach. What I actually need is the intersection between two ranges.</p>