简体   繁体   中英

Google apps script timestamp

I am building a GAS timestamp function in google spreadsheet which will change the timestamp whenever I revise the cell value in column 10. However, The cell I'd revise now is filled with IFS function , which actually will change itself. The IFS function results to the original timestamp function stop working cause literally the cell value has not changed. Wanna ask if there's any way that I can solve this problem, so that GAS and spreadsheet function could work together smoothly.

function onEdit(e) {
  
  var row = e.range.getRow();
  var col = e.range.getColumn();
  
  if(col == 10 && row >1 && e.source.getActiveSheet().getName() === "Sheet 1" ){
    e.source.getActiveSheet().getRange(row, 3).setValue(new Date());
  }
}

You should review the IFS formula precedent dependencies to find which cells are actually edited by a user then, instead of looking for "edits" on the cells with that formula use the precedent cells .

ie Let sayt that you have the following formula in B1 .

=A1+1

instead of looking for "edits" on B1 look for edits on A1 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM