Skip to content

Instantly share code, notes, and snippets.

View RomainVialard's full-sized avatar

Romain Vialard RomainVialard

View GitHub Profile
@RomainVialard
RomainVialard / Get indexes of selected rows.gs
Last active August 16, 2024 00:32
Google Apps Script - Google Sheets - Use the getActiveRangeList() method to get indexes of selected rows
function myFunction() {
const sheet = SpreadsheetApp.getActiveSheet();
const data = sheet.getDataRange().getValues();
const selectedRows = getIndexesOfSelectedRows(sheet);
for (let i = 0; i < data.length; i++) {
// skip not selected rows
if (!selectedRows.includes(i + 1)) continue;
const rowData = data[i];
console.log(rowData);
// perform the relevant action: generate a document, send an email,...