Google Spreadsheets - Timestamp issue.

94 views
Skip to first unread message

zeromax dispatch

unread,
May 29, 2019, 1:04:07 PM5/29/19
to Google Apps Script Community

Hello World!

  I'm just having an issue with google spreadsheets. I need to create a function (probably in script editor). This function should put automatic timestamp in cloumn D first time when a change made in column C. And this timestamp should be static.
  However, other time (2nd, 3d and etc) when a change made in column C new timestamp should be added to column E and it should be updated every time when a change is made in column C.

 Can you please help how to do it or share ready code.

Clay Smith

unread,
May 29, 2019, 1:33:46 PM5/29/19
to google-apps-sc...@googlegroups.com
You will have to hook this into an onEdit trigger. 
function timeStamp(e){
  var ss= SpreadsheetApp.getActiveSpreadsheet(); //get the active spreadsheet
  var sheet = ss.getActiveSheet(); //get the active sheet
  var thisRow = e.range.getRow(); //identify the row number of the edited cell
  var thisCol = e.range.getColumn(); //identify the column number of the edited cell
  if (thisCol = 3){ //if the column number is 3 meaning C then...
    if(sheet.getRange(thisRow, 4).getValue()==''){ //Check if the cell in column 4 meaning D is empty. if it is...
      sheet.getRange(thisRow, 4).setValue(new Date); //Set the column 4 cell on the edited row with a new date, ie timestamp adjust your Number format. 
    }else{
      sheet.getRange(thisRow, 5).setValue(new Date); //if the column 4 has something in it then put a new timestamp in column 5
    }
  }
}

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-script-community.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/7012084d-f305-4154-913b-e12d47090595%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages