I'm using a script to add a timestamp when a value on a given row is changed. My issue I'm running into is that the getSheetByName
isn't returning the sheet I want, rather the script is running across all 15+ sheets on the file. What am I doing wrong?
function onEdit() {
var s = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("LeadTracker");
var r = s.getActiveCell();
if( r.getColumn() != 2 ) { //checks the column
var row = r.getRow();
var time = new Date();
time = Utilities.formatDate(time, "GMT-06:00", "MM-dd-yy, hh:mm:ss");
SpreadsheetApp.getActiveSheet().getRange('R' + row.toString()).setValue(time);
};
};