Home > Enterprise >  Run a script when cell contains specific values
Run a script when cell contains specific values

Time:01-29

I am looking to run one of two scripts based off two specific values in cell G13. I need it to first clear the contents of the cell with the indicated value then run the particular script that is associated with that particular value. Hoping this is not too difficult and thank you ahead of time!

If G13 contains "search", then would like to wipe that specific cell first and then run this script

enter script

If G13 contains "submit", then would like to wipe that specific cell first and then run this script:

enter script

CodePudding user response:

function onEdit(e) {
  const sh = e.range.getSheet();
  if(sh.getName() == "Your sheet name" && e.range.columnStart == 7 && e.range.rowStart == 13 && e.value == "search") {
   //add your script here
  }
  if(sh.getName() == "Your sheet name" && e.range.columnStart == 7 && 
    e.range.rowStart == 13 && e.value == "submit") {
   //add your script here
  }
}

or something like this:

function onEdit(e) {
  const sh = e.range.getSheet();
  if (sh.getName() == "Your sheet name" && e.range.columnStart == 7 && e.range.rowStart == 13) {
    if (e.value == "submit") {
      //add your script here
    } else if (e.value == "search") {
      //add your script here
    }
  }
}
  •  Tags:  
  • Related