How do I get the selected cell / range?

Is there a way to get the identification (like A1 notation) of the selected cell or range in Google Sheets?

Something like:

=SELECTION(['Sheet1']) -> "D6"

      

+3


source to share


1 answer


This custom function will receive the selection when the cell is updated with the function. But when the selection changes, it won't update.

Henrique gives a good explanation as to why custom functions like this are not updated in Google Apps - a script to summarize data not being updated .



/**
 * A function that gets the current selection, in A1Notation.
 *
 * @customfunction
 */
function SELECTED_RANGE() {
  return SpreadsheetApp.getActive().getActiveRange().getA1Notation();
}

      

+7


source







All Articles