Is there a way to get the identification (i.e. A1 notation) of a selected cell or range in Google Sheets?
Something like:
=SELECTION(['Sheet1']) -> "D6"
Is there a way to get the identification (i.e. A1 notation) of a selected cell or range in Google Sheets?
Something like:
=SELECTION(['Sheet1']) -> "D6"
This custom function will get the selection at the time you update the cell with the function. But it will not update as the selection changes.
Henrique provides a good explanation of why custom functions like this don't update in Google Apps - script to summarise data not updating.
/**
* A function that gets the current selection, in A1Notation.
*
* @customfunction
*/
function SELECTED_RANGE() {
return SpreadsheetApp.getActive().getActiveRange().getA1Notation();
}
One way to get the reference of the cell holding formula using only Google Sheets built-in functions is
=ADDRESS(ROW(), COLUMN())
From a OP's comment to the question
I meant a spreadsheet function. I wanted to bring some interactivity to the sheet, so it would react to cell selection change. (Range not included). Last time I checked, that's was not possible. – Ondra Žižka Oct 14, 2018 at 18:09
The built-in function to get a cell "identification", aka, reference, is ADDRESS. This function has existed for a long time, but I don't remember needing to handle the use case shown in the question, only to return the cell reference, before finding this question.
While using a custom function (Google Apps Script / JavaScript function) might do the same, this option might be overkilling and not so convenient:
© 2022 - 2024 — McMap. All rights reserved.