range.contains()

GASapprange ⟩ .contains()

// 🔸 app.range.contains(superRange, subRange)
app.range.contains = function(superRange, subRange) {

  // get first row #
  let r11 = superRange.getRow();
  let r21 = subRange.getRow();
  if (r11 > r21) return false;

  // get last row #
  let r12 = r11 + superRange.getNumRows() - 1;
  let r22 = r21 + subRange.getNumRows() - 1;
  if (r12 < r22) return false;

  // get first col #
  let c11 = superRange.getColumn();
  let c21 = subRange.getColumn();
  if (c11 > c21) return false;

  // get last col #
  let c12 = c11 + superRange.getNumColumns() - 1;
  let c22 = c21 + subRange.getNumColumns() - 1;
  if (c12 < c22) return false;

  return true;
}

Last updated