简体   繁体   English

根据Google电子表格中另一个单元格的值,阻止单元格被编辑

[英]Block a cell from being edited based on the value in another cell in Google spreadsheet

I am trying to figure out how to block a cell based on the value in another adjacent cell in my Google spreadsheet. 我正在尝试找出如何根据我的Google电子表格中另一个相邻单元格中的值来阻止一个单元格。

In my Google spreadsheet, both column A and column B have a dropdown list. 在我的Google电子表格中,列A和列B都有一个下拉列表。 I want cell B1 to be locked if a particular item is selected from the dropdown in column A. 如果要从A列的下拉列表中选择特定项目,我希望单元格B1被锁定。

I ran across a link that is similar, but I do not know how to adjust it to meet my needs. 我遇到了一个相似的链接,但是我不知道如何调整它以满足我的需求。 Is this something that can be done? 这是可以做到的吗?

To monitor the state of a certain cell, you can use either a simple or installable trigger. 要监视某个单元的状态,可以使用简单或可安装的触发器。 A simple trigger only needs a certain function name, no other setting. 一个简单的触发器只需要一个特定的功能名称,而无需其他设置。

function onEdit(e){
  // Get what range was edited
  var range = e.range;

  //Check the range address
  if (range === "A1") { //If range edited was the cell A1, then do something
    //Get the value in the edited cell
    var valueInCell = e.value;

    //Run a condition check
    if (valueInCell === edit Value Here) {
     //Get reference to cell to act upon

      //To Do: code here

    //Do something to cell

      //To Do: code here
    };
  };
};

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 根据单元格中的值将行的一部分从一个 Google 电子表格复制到另一个 Google 电子表格? - Copying part of a row from one Google spreadsheet to another google spreadsheet based on a value in a cell? 更简单地检查单元格是否已编辑并插入了特定值(Google电子表格脚本) - Simpler check if a cell was edited and a certain value inserted (Google spreadsheet script) 如何根据单元格中的值将一行从一个Google电子表格移动到另一个? - How to move a row from one google spreadsheet to another based on a value in a cell? Google 电子表格:根据该行中的单元格值从范围复制行 - Google spreadsheet :Copying row from a range based on a cell value in that row 通过按钮将值从Google电子表格中的特定单元格复制到另一个单元格 - Copy value from specific cell in google spreadsheet to another via button 如何基于Google Spreadsheet中的另一个单元格设置单元格的背景色? - How to set background colour of a cell based on another cell in Google Spreadsheet? 谷歌脚本如何根据正在编辑的一个单元格发送电子邮件 - Google Script how to send email based on ONE cell being edited "根据谷歌电子表格中的单元格颜色更改单元格值" - Change cell value based on cell color in google spreadsheet 用于将Google电子表格行的部分内容复制到另一个电子表格并全部基于单元格添加值的脚本 - Script for copying parts of a google spreadsheet row to another spreadsheet and adding a value all based on a cell Google电子表格。 如何根据编辑的单元格更新单元格值 - Google spreadsheet. How to update cell value depending on which cell was edited
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM