1
votes

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?

1
You could use a simple onEdit() trigger, that monitors the state of the cell in column A, then acts upon the cell B1. Google Documentation - Alan Wells

1 Answers

0
votes

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