【问题标题】:How to Get the currently selected cell/range?如何获取当前选定的单元格/范围?
【发布时间】:2015-06-11 11:23:37
【问题描述】:

有没有办法在 Google 表格中获取选定单元格或范围的标识(即 A1 表示法)?

类似:

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

【问题讨论】:

  • 使用 getActiveRange() 你可以阅读它here
  • 您的意思是作为电子表格中的函数,还是使用google-apps-script
  • 我的意思是电子表格函数。我想给工作表带来一些交互性,所以它会对单元格选择的变化做出反应。 (不包括范围)。上次我检查时,这是不可能的。

标签: google-apps-script google-sheets selection


【解决方案1】:

此自定义函数将在您使用该函数更新单元格时获得选择。但它不会随着选择的变化而更新。

Henrique 很好地解释了为什么像这样的自定义函数不会在 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();
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-16
    • 1970-01-01
    • 2018-11-12
    • 1970-01-01
    • 1970-01-01
    • 2021-12-19
    相关资源
    最近更新 更多