P
P
paroletatel2021-08-09 11:05:37
Google Apps Script
paroletatel, 2021-08-09 11:05:37

How to get data from a non-continuous range selected via Ctrl?

I select the range through Ctrl:
6110e1b0dbf51266559120.png
And there is a code:

function myFunction() {
var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet()
var val = ss.getActiveRange().getValues()
Logger.log(val)
}

Which returns:
Information

That is, only the last piece of the selected range.
Is there any way to get the entire selected array?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
paroletatel, 2021-08-09
@paroletatel

function myFunction() {
var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet()
var arr = ss.getActiveRangeList().getRanges()
var val = []
for(let i = 0; i<arr.length;i++){
  val.push(arr[i].getValues())
}
Logger.log(val)
}

An object of type rangelist helped.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question