当单元格值更改为“值”时更改单元格范围

时间:2017-10-12 15:55:38

标签: google-apps-script google-sheets

我正在尝试更改单元格范围工作表!L2:L20为空白时,Newsletter!K6更改为“已完成”

function onEdit(e) {
      var sheet1 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Newsletter");
      var sheet2 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Worksheet");
      var cell = sheet1.getRange(6,11).getValues();
      var cells = sheet2.getRange(2,12,20);
      var finished = "FINISHED";

      if (cell === "FINISHED") {

      cells.setValue("");

      } else {

      }
    }

1 个答案:

答案 0 :(得分:0)

将onEdit缩小到要监视的工作表和单元格,然后执行以下操作:

function onEdit(e){
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = e.source.getActiveSheet().getName()
  var editedCell = e.range.getSheet().getActiveCell().getA1Notation();
  if(sheet=="Newsletter"){
  if(e.value=="FINISHED"){
     ss.getRange("Worksheet!L2:L20").clearContent() 
  }}}