Skip to content Skip to sidebar Skip to footer

Correct Syntax For OnEdit Trigger

I'm trying to get an app that somebody else wrote to call the function each time the spreadsheet is edited. I've been looking at the google developers website https://developers.g

Solution 1:

onEdit is an event handler. you wont be able to return something from it. just initialise i outside, i.e., to the global scope.

var i = 0;    
function onEdit(range) {
      var ss = SpreadsheetApp.getActiveSpreadsheet();
      var sheet = ss.getActiveSheet();



      var r = sheet.getRange(range);

      var colors  = r.getBackgroundColors();

      for(c in colors) {

        if(colors[c] != "white") {
          i++;
        }
      }


    }

Post a Comment for "Correct Syntax For OnEdit Trigger"