【问题标题】:Make the column values static in Google sheets在 Google 表格中将列值设为静态
【发布时间】:2021-07-01 20:52:14
【问题描述】:

我在谷歌表格中有两列。第一列column A 是输入列,第二列column B 是输出列。一旦我在第一列中输入值,我希望第二列中的值是静态的。 (因为第二列中的结果是基于第一列中输入的值)

【问题讨论】:

  • 静态是什么意思?如果你改变输入,那么输出就会改变。
  • 我的意思是 - 在 A 列中所做的任何更改/输入都不应更改 B 列中已经生成的值
  • 那你需要脚本(公式不行)。
  • 当然。这样就可以了。

标签: google-sheets google-sheets-formula


【解决方案1】:

这是一个基本脚本,它将值置于已编辑单元格的右侧并将其设为“静态”:

function onEdit(e) {
  var staticCell = e.range.offset(0,1); // Finds the cell to the right of the edited one
  var staticVal = staticCell.getValue(); // Gets the value of that cell

  staticCell.setValue(staticVal); // Sets the cell value to itself, removing the formula and making the cell "static"
}

这是另一个执行相同操作的脚本,但仅在编辑 A 列时才有效(针对此问题):

function onEdit(e) {
  var staticCell = e.range.offset(0,1);
  var staticVal = staticCell.getValue();

  if(e.range.columnStart == 1){ // Checks to see if the edited cell is in column A
    staticCell.setValue(staticVal);
  } else {}; // If it is not in column A, nothing happens
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-09
    • 1970-01-01
    • 1970-01-01
    • 2021-08-06
    • 2016-03-02
    • 1970-01-01
    相关资源
    最近更新 更多