简体   繁体   中英

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.

In my Google spreadsheet, both column A and column B have a dropdown list. I want cell B1 to be locked if a particular item is selected from the dropdown in column A.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM