Process only selected rows in scripts and add-ons

It is super easy in Google Sheets to select only specific rows, even if they are not adjacent. Simply hold down the CTRL / command key while making your selections:

Select Non-Adjacent rows in Google Sheets

This can be useful to copy selected rows in another sheet, delete a bunch of rows,…

And those selections are also available in Google Apps Script via the method getActiveRangeList()😍. Thus, add-ons which perform a specific action on each row in a spreadsheet can target only those selected rows.

We have implemented this new feature in Mergo, our mail merge add-on and Publigo, our document merge add-on.

If you selected 1 or more rows, Publigo lets you generate a personalized document for those rows only or all visible rows in your sheet.

Until now, those add-ons would process all visible rows (they correctly detect which rows have been hidden or filtered out 🕵️) while making sure no duplicate email is sent (Mergo) and no duplicate PDF is generated (Publigo).

But often users want to perform a merge on a single or a few records only: to test with different examples / email addresses before going through the full list or because they are always using the same contact list and generate documents as needed:

I have medical consultations with patients and generate a letter for them after each visit. I use several letter templates for each patient over time (first visit, surgery, first follow up, second follow up etc.). The patient details are stored in a spreadsheet. If for example a patient comes for their first follow up visit, I would click on the patient’s details in my spreadsheet, open my “First follow up” template and use Publigo to print a pdf with all the relevant fields populated automatically.

This is now super easy with Mergo & Publigo. 👍

For Google Apps Script developers, here is a quick snippet showing how to process only selected rows.

--

--

--

Google Developer Expert, creator of several successful add-ons for Gmail, Drive,...

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Fix rbenv or ruby command not found after changing from bash to zsh

6 Online Communities About Difference between odoo enterprise vs community You Should Join

Using Arduino’s New Oplà Kit to Read Remote Sensors and Display the Data in Your Home

Code that debugs itself: Fixing a deadlock with a watchdog

[Leetcode] Best Time to Buy and Sell Stock

Balancing the enemy spawn rates

Handle User Accounts & Authentication in Flask with Flask-Login

In this video, We are discussing the Life cycle of automation Testing, This is Day 1 of the series…

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Romain Vialard

Romain Vialard

Google Developer Expert, creator of several successful add-ons for Gmail, Drive,...

More from Medium

How to Choose The Best Ontology Structure for Your Model | Dataloop Blog

Computational Photography Series — Three Frames One Image

Analytical Hockey Player Rankings — Part 3: The Actual Rankings

How Useful is Web Application Framework?