Formula-based cell changes in Google Sheets is not firing onEdit script -


i'm new google script writing, i've used various posts here piece need: add time stamp row when column changes. here's i'm using:

function onedit() {   var s = spreadsheetapp.getactivesheet();   if( s.getname() == "test" ) { //checks we're on correct sheet     var r = s.getactivecell();     if( r.getcolumn() == 16 ) { //checks column       var nextcell = r.offset(0, 1);       if( nextcell.getvalue() === '' ) //is empty?         nextcell.setvalue(new date());     }   } } 

this works when manually change data; however, column script monitoring pulls data sheet , fails fire trigger/script. how can around cells formulas (that reference other sheets) still fire script?

any appreciated. thanks!

the onedit trigger works when actual user edits spreadsheet. depends of use case, can use time-driven trigger , set in recurring interval , function monitor column changes, here's example:

function monitorcolumn() {   // add trigger resources menu in script editor   // script editor > resources > current oroject's triggers > add trigger   // [monitorcolumn] - [time-driven] - [hour timer] - [every hour]    var s = spreadsheetapp.getactivespreadsheet();   var ss = s.getsheetbyname("test"); // sheet name    // values of columns p & q getrange(row, column, numrows, numcolumns)   var columnvalues = ss.getrange(1, 16, ss.getlastrow(), 2).getvalues();    // loop through values   (var = 0; < columnvalues.length; i++) {      // if cell in column p empty , cell in column q not empty set todays date     if(columnvalues[i][0] != "" && columnvalues[i][1] == ""){        // while range index starts @ 1, 1, javascript array indexed [0][0].       ss.getrange(i+1,17).setvalue(new date());     }   } } 

Comments