0
votes

The following code is activating a range in columns G to I from row 4. The ending row is depending on the based on the length of data in column B.

function seleziona() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  SpreadsheetApp.setActiveSheet(ss.getSheetByName('Sheet1'));
  var sheetActive = SpreadsheetApp.getActiveSpreadsheet();
  var sheetActive = SpreadsheetApp.getActiveSheet();
  var Avals = sheetActive.getRange("B4:B").getValues();
  var Alast = Avals.filter(String).length;
  sheetActive.getRange(4, 7, Alast, 3).activate();
}

I was wandering if there is a way to have a multiple selection (e.g. with getRangeList)that is taking the selection of the above code + the following range: getRange(358, 7, 8, 3)

1
For documentation purposes if you can, please accept the answer (✓) that's been helpful to you - it helps other people that have the same issue in the future find the solution too :)I hope this is helpful to you

1 Answers

1
votes

I believe your goal as follows.

  • You want to activate the range of sheetActive.getRange(4, 7, Alast, 3) and sheetActive.getRange(358, 7, 8, 3) using the range list.

In this case, as a simple modification, how about the following modification?

From:

sheetActive.getRange(4, 7, Alast, 3).activate();

To:

var rangeList = [
  sheetActive.getRange(4, 7, Alast, 3).getA1Notation(),
  sheetActive.getRange(358, 7, 8, 3).getA1Notation(),
];
sheetActive.getRangeList(rangeList).activate();

Note:

  • If you want to active the range of "Sheet1", you can also use the following modified scriot.

      var ss = SpreadsheetApp.getActiveSpreadsheet();
      var sheetActive = ss.getSheetByName('Sheet1');
      var Avals = sheetActive.getRange("B4:B").getValues();
      var Alast = Avals.filter(String).length;
      var rangeList = [
        sheetActive.getRange(4, 7, Alast, 3).getA1Notation(),
        sheetActive.getRange(358, 7, 8, 3).getA1Notation(),
      ];
      sheetActive.getRangeList(rangeList).activate();
    

References: