Skip to content

Instantly share code, notes, and snippets.

@joshm21
Last active April 10, 2020 05:02
Show Gist options
  • Save joshm21/650b244ce76615c55b6fd112ca0b1b06 to your computer and use it in GitHub Desktop.
Save joshm21/650b244ce76615c55b6fd112ca0b1b06 to your computer and use it in GitHub Desktop.
Split range into an array of ranges representing the rows of the original range #google-apps-script #range
function splitRangeIntoRows(range) {
const sheet = range.getSheet();
const firstRow = range.getRow();
const lastRow = firstRow + range.getNumRows() - 1;
let rows = [];
for (let rowIndex = firstRow; rowIndex <= lastRow; rowIndex++) {
rows.push(sheet.getRange(`${rowIndex}:${rowIndex}`));
}
return rows;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment