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