Wednesday, August 29, 2012

How to know who has modified a cell and at what time

How to know who has modified a cell and at what time


Following script will let you know which cell has been modified by which user, in the comment of that particular cell itself:


function onEdit(e)
{
  myFunction();
}

function myFunction()
{
  var sheet = SpreadsheetApp.getActiveSheet();
  
  var date = Utilities.formatDate(new Date(), "GMT+0530", "dd-MM-yy HH:mm");
  var actRng = sheet.getActiveRange();
  var rowindex = actRng.getRowIndex();
  var colindex = actRng.getColumnIndex();
  var thisCell = sheet.getRange(rowindex,colindex);

  var userEmail = Session.getEffectiveUser();
  thisCell.setComment("'" + date + " " + userEmail);
}



If you don't know how to write a script, or where to write this above script then look at the following link which will help you out:

http://igoogledrive.blogspot.in/2012/08/how-to-write-script-in-google.html


I hope the above solution will help you, and if you need more help then please do comment below on this blog itself I will try to help you out.

If this blog post was helpful to you, and if you think you want to help me too and make my this blog survive then please donate here: http://igoogledrive.blogspot.com/2012/09/donate.html 




Thanks,
Kishan,

4 comments:

  1. Thanks for the temporary work around to the comment stamp, Kishan! It's not perfect, but we'll trying to make this work for us...

    With this new script, the main problems are now that literally every cell which has content now also has a comment with the date/time stamp, its a bit extraneous. Additionally, we are unable to add any other notes in the comment fields, as they are overwritten with a new stamp anytime the cell content is edited.

    I'm very new to scripts... Can you tell me if there is a way to tweak it, as to apply the script only to, say Column C for instance?
    Thanks again for your help!

    ReplyDelete
    Replies
    1. Hi Scarlett,

      Yes, it can be done...
      I will try to implement it as soon as I get free...

      And if you want it in urgent, then please check out the following link:
      http://igoogledrive.blogspot.in/p/paid-projects.html

      Thanks,
      Kishan.

      Delete
  2. I wonder if i can make a Script for Edited HH:MM ago.

    ReplyDelete
    Replies
    1. Hi Ivan,

      Yes, it can be done...
      I will try to implement it as soon as I get free...

      And if you want it in urgent, then please check out the following link:
      http://igoogledrive.blogspot.in/p/paid-projects.html

      Thanks,
      Kishan.

      Delete