Indication of which line to run in GoogleEdit Google Script

I want this onEdit script in Google Sheets to start with line 2, which skips my title bar, but I can’t get it to work with my existing code? Can someone out there help noob?

function onEdit(e) { var ss = e.source.getActiveSheet(); var rr = e.source.getActiveRange(); //comment 2 lines below if you want it working on all sheets, not just on 2nd one if(ss.getIndex()!= 1) if(ss.getIndex()!= 2) if(ss.getIndex()!= 3) return; /// var firstRow = rr.getRow(); var lastRow = rr.getLastRow(); //the last modified date will appear in the 43th column which is the Last Update Column for(var r=firstRow; r<=lastRow; r++) ss.getRange(r, 43).setValue(new Date()); } 
0
source share
1 answer

Just check if the current line is inside the header and exit the trigger:

 function onEdit(e) { var rr = e.range; var ss = e.range.getSheet(); var headerRows = 1; // # header rows to ignore if (rr.getRow() <= headerRows) return; ... 
+1
source

Source: https://habr.com/ru/post/979129/


All Articles