Get active range or active cell object

Source code

function getActiveRangeObject(){
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sh = ss.getActiveSheet();
  var rng;

  // (1) Get active range
  rng = sh.getActiveCell();
  rng = sh.getActiveRange();
  rng = sh.getCurrentCell();
}

 

Format

(1) SheetObject.getActiveCell() … Get active cell object

(2) SheetObject.getActiveRange() … Get active range object

(3) SheetObject.getCurrentCell() … Get active cell object

 

Returns

Range object