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).
Selected ranges in a Google Sheet |