Get Spreadsheet cell calling a custom function

前端 未结 1 1991
萌比男神i
萌比男神i 2021-01-22 14:27

I am trying to figure out how to get the A1 Notation of a Cell calling a Custom Function.

I found this but this is for active cell. https://webapps.stackexchange.com/que

1条回答
  •  半阙折子戏
    2021-01-22 14:57

    There are subtle differences in different range returning method names- active,current,selection:

    The term "active range" refers to the range that a user has selected in the active sheet, but in a custom function it refers to the cell being "active"ly recalculated.

    The current cell is the cell that has focus in the Google Sheets UI, and is highlighted by a dark border.

    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 first two are still range objects,while the latter is not.

    I want the function to return the text value A5.

    Without Custom Functions,We can use:

    =ADDRESS(ROW(),COLUMN())
    

    With Custom function,We can use:

    function test() { 
     return SpreadsheetApp.getActiveRange().getA1Notation(); 
    }
    

    0 讨论(0)
提交回复
热议问题