There is another way that I used recently. Each time onEdit () is triggered, it returns an event (e) object , which gives you valuable information about what is happening.
For example, it gives you a range that you can get from e.range. From there, you can crosswise in different ways and find out, for example, which line is being edited. But there is more useful data in the e-object. It gives you the "oldvalue" ( e.oldValue ) of the changed cell and the new value ( e.value ).
One possible way to combine all of this information would be to get a range that matches the row you are editing, and then check to see if there are any cells in it (but the one you just edited) and if there is no oldValue.
This is not the last row of your table, but empty. If you agree on how you fill out your details, this may work for you:
//val = inserted value (e.value); //old = old Value (e.oldValue); //col = number of column being edited //arr = array with the indexes of the columns that should be completed so as to make a new row [0,1,2...n] function isInsert(old, val, col, arr){ if((typeof val != "object")&&!old&&(arr.some(isNotEmpty, col))) return true; else return false; } function isNotEmpty(el){ if(this == el) return true; }
Diego source share