Access the current active selection in the active sheet. A selection is the set of cells the user
has highlighted in the sheet, which can be non-adjacent ranges. One cell in the selection is the
current cell, where the user's current focus is. The current cell is highlighted with a
darker border in the Google Sheets UI.
var activeSheet = SpreadsheetApp.getActiveSheet();
var rangeList = activeSheet.getRangeList(['A1:B4', 'D1:E4']);
rangeList.activate();
var selection = activeSheet.getSelection();
// Current Cell: D1
Logger.log('Current Cell: ' + selection.getCurrentCell().getA1Notation());
// Active Range: D1:E4
Logger.log('Active Range: ' + selection.getActiveRange().getA1Notation());
// Active Ranges: A1:B4, D1:E4
var ranges = selection.getActiveRangeList().getRanges();
for (var i = 0; i < ranges.length; i++) {
Logger.log('Active Ranges: ' + ranges[i].getA1Notation());
}
Logger.log('Active Sheet: ' + selection.getActiveSheet().getName());
Access the current active selection in the active sheet. A selection is the set of cells the user has highlighted in the sheet, which can be non-adjacent ranges. One cell in the selection is the current cell, where the user's current focus is. The current cell is highlighted with a darker border in the Google Sheets UI.