Tuesday, 15 January 2013

How can I set up a datestamp in Google Sheets for specific rows? -



How can I set up a datestamp in Google Sheets for specific rows? -

i trying set google sheets spreadsheet where, when specific cell edited, date in cell right updates indicate alter has been made. on google sheets forum, directed me here best guidance.

the script working perfectly. however, i'd limit specific cells (or rows--either work) not add together date stamp header rows. need add together script apply specific cells/rows?

here's script now:

function onedit() { var s = spreadsheetapp.getactivesheet(); var r = s.getactivecell(); if( r.getcolumn() != 3 ) { //checks 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 have sheet 30 active rows. want datestamp appear in rows 9 through 13; 15 through 18; , 20 through 26. other rows headers , want able alter text there without sheets populating adjacent cell datestamp. how go editing script accomplish in google sheets, assuming it's possible? give thanks you!!

just add together more conditions column condition.

for illustration 2 first series of rows :

if( r.getcolumn() != 3 && ((row>8 && row<14)||(row>14 && row<19))){ // go on other , and or conditions

btw, suggest replace hard coded time zone dedicated method :

var tz = session.getscripttimezone(); var time = utilities.formatdate(new date(),tz, "mm/dd/yy");

it match time zone of sheet automatically, if in country has daylight savings.

google-apps-script

No comments:

Post a Comment