0

I am trying to create custom function in google sheets, where the function returns the reference of whatever cell the active user is in.

I had a lot of issues with Oauth permissions etc, but eventually got everything worked out by just using this code referenced here:

https://stackoverflow.com/a/30814944/19598411

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

What occurs is that the function does not update due to googles caching behaviour as Mogsdad references, and Henrique explains here: https://stackoverflow.com/a/9023954/19598411

I've tried to solutions referenced in this thread without any success.

Is there any way of creating what I'm trying to achieve?

Thanks.

Switch
  • 1
  • You mean, you want to update the field with that function whenever the user selects a new cell? I don't think that's possible. Your problem doesn't seem to be related to that other issue, as you aren't passing in any arguments. A function will not re-evaluate just because something on the sheet changed. It has to be the argument value that triggers the change. If I understand your problem correctly, I believe the only way to solve it would be for the user to click on a shape that has an assigned function or select a menu that updates the desired target cell – johndee31415 Jul 22 '22 at 11:16
  • It's not clear to me what you wish to accomplish but take a look at onSelectionChange trigger – Cooper Jul 22 '22 at 13:12

0 Answers0