How to generate range ID hyperlink, #rangeID=XXXXXXXXXX, in Google Sheets using Scripts?

后端 未结 2 1977
时光说笑
时光说笑 2021-02-13 12:37

So recently, Google added the feature where you can hyperlink to a specific cell, which is great. To do so, you use the \"Insert link\" feature on a specific cell, and then from

相关标签:
2条回答
  • 2021-02-13 13:01

    This is a perfect use case for named ranges, and it doesn't require any change to your script logic.

    var range = ss.getRangeByName("NamedRange1");
    
    0 讨论(0)
  • 2021-02-13 13:06

    You can use a relative url. The answer in a linked document can be found here https://webapps.stackexchange.com/questions/44473/link-to-a-cell-in-a-google-sheets-via-url.

    Example:

    =hyperlink("#gid=0&range=A2",Bookmarks!A2)

    I think #gid=0 represents the first sheet. Then I can specify the range in the sheet. I was unable to get named sheets working. Besides the first sheet/tab the others all have a #gid which you can find in the url of that sheet.

    Ex:

    =hyperlink("#gid=1756281106&range=A2",Bookmarks!A2)

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