Script sometimes it works sometimes it dosent

google sheetsgoogle-apps-scriptgoogle-apps-script-triggers

I have 2 columns to enter Lat and Long coordinates in ( E and F ), those also contain the Formulas (for all rows, I just happened to choose row 768below)

=IFERROR("N"&left(index(Split(D768,"N"),1),11),"") 

and

=IFERROR("W"&index(Split(D768,"W"),2),"")

Because 75% of the time the full set of Coords can be pasted in D in which case the above seems to work fine in breaking it up into E and F properly or accepting manual input

The problem I'm having is with a script (copy below) that looks for changes in E and F and if so puts today's date in H. With Manual entries in E and F the script works great, with the Cut and Paste into D

however, it only works sometimes (maybe 10%). I could understand it either not working at all (because maybe using a formula not considered an edit?) or working all the time – But why does it work sometimes and/or how to fix it.

Script

function onEdit(e) {
 if ([5].indexOf(e.range.columnStart) != -1) {
 e.range.offset(0, 3).setValue(new Date());
 }
 if ([6].indexOf(e.range.columnStart) != -1) {
 e.range.offset(0, 2).setValue(new Date());
 }
}

Best Answer

Your assumption is correct. Changes in formula only, does not count as "onEdit change".

The onEdit(e) trigger runs automatically when a user changes the value of any cell in a spreadsheet. Most onEdit(e) triggers use the information in the event object to respond appropriately. For example, the onEdit(e) function below sets a comment on the cell that records the last time it was edited. An installable edit trigger runs when a user modifies a value in a spreadsheet.

https://webapps.stackexchange.com/a/119702/186471