AppsScriptPulse

Get all selected Ranges in Google Sheets with Google Apps Script

Get all selected Ranges in a Google Sheet along with values, row and column details.

Selected ranges in a Google Sheet

Selected ranges in a Google Sheet

The following Google Apps Script was from some learning around multiple ranges being selected/highlighted by a user in a Google Sheet. I have always worked with individual cells or continuous ranges within Sheets, but during the development of my Archive Sheet data Add-on I wanted to enhance it by allowing more rows to be acted upon in one go.

I practiced getting a few values after looping through each selected range:

  • A1 Notation (e.g. A2:C5),
  • Cell values,
  • Starting row,
  • End row,
  • Number of rows (calculated from the above),
  • Starting column,
  • End column,
  • Number of columns (calculated from the above).

Source: The Gift of Script: Get all selected Ranges in a Google Sheet

Leave a Reply

Your email address will not be published. Required fields are marked *