I am trying to set up a Google Sheets spreadsheet where, when a specific cell is edited, the date in the cell to the right updates to indicate that a change has been made. On the Google Sheets forum, someone directed me here for the best guidance.
The script itself is working perfectly. However, I'd like to limit it to specific cells (or rows--either will work) so that it does not add a date stamp to my header rows. What do I need to add to the script to apply this to specific cells/rows?
Here's my script as it is now:
function onEdit() {
var s = SpreadsheetApp.getActiveSheet();
var r = s.getActiveCell();
if( r.getColumn() != 3 ) { //checks the column
var row = r.getRow();
var time = new Date();
time = Utilities.formatDate(time, "GMT-07:00", "MM/dd/yy");
SpreadsheetApp.getActiveSheet().getRange('C' + row.toString()).setValue(time);
};
};
Hypothetically, let's say that I have a sheet with 30 active rows. I want the datestamp to appear in Rows 9 through 13; 15 through 18; and 20 through 26. The other rows are all headers and I want to be able to change the text there without Sheets populating the adjacent cell with a datestamp. How would I go about editing the script to achieve this in Google Sheets, assuming it's possible? Thank you!!