如何获取当前选择的单元格/范围? [英] How to Get the currently selected cell/range?

查看:29
本文介绍了如何获取当前选择的单元格/范围?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Is there a way to get the identification (i.e. A1 notation) of a selected cell or range in Google Sheets?

类似于:

=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 在 Google Apps - 汇总未更新数据的脚本.

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();
}

这篇关于如何获取当前选择的单元格/范围?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆