Skip to content

Instantly share code, notes, and snippets.

View CarbonSplinter's full-sized avatar

CarbonSplinter

View GitHub Profile
@tallcoleman
tallcoleman / Intersect.gs
Last active June 12, 2025 12:31
Intersect() function for Google Apps Script
/**
* Returns the intersection of two ranges, or null if there is no overlap.
* @param {SpreadsheetApp.Range} r1 Range 1
* @param {SpreadsheetApp.Range} r2 Range 2
* @returns {SpreadsheetApp.Range}
*/
function Intersect(r1, r2) {
if (r1.getSheet().getSheetId() !== r2.getSheet().getSheetId()) return null;
const FIRSTROW = Math.max(r1.getRow(), r2.getRow());