1

How should I modify the script, in a way that it would work also in another column, eg. by putting data in A:A date will be printed in B:B and also in C:C

function onEdit() {
  var sheetName = "MySheet";
  var s = SpreadsheetApp.getActiveSheet();
  if (s.getName() !== sheetName) return;
  var r = s.getActiveCell();
  if( r.getColumn() != 2 ) { //checks the column
    var row = r.getRow();
    var time = new Date();
    time = Utilities.formatDate(time, "GMT+05:30", "dd-MM-yyyy, hh:mm a");
    SpreadsheetApp.getActiveSheet().getRange('B' + row.toString()).setValue(time);
  };
 };
-1

try this:

function onEdit() {
  var sheetName = "MySheet";
  var s = SpreadsheetApp.getActiveSheet();
  if (s.getName() !== sheetName) return;
  var r = s.getActiveCell();
  if( r.getColumn() != 2 ) { //checks the column
    var row = r.getRow();
    var time = new Date();
    time = Utilities.formatDate(time, "GMT+05:30", "dd-MM-yyyy, hh:mm a");
    SpreadsheetApp.getActiveSheet().getRange('B' + row.toString()).setValue(time);
  };
  if( r.getColumn() != 3 ) { //checks the column
    var row = r.getRow();
    var time = new Date();
    time = Utilities.formatDate(time, "GMT+05:30", "dd-MM-yyyy, hh:mm a");
    SpreadsheetApp.getActiveSheet().getRange('C' + row.toString()).setValue(time);
  };
 };
  • docs.google.com/spreadsheets/d/… ,,,,,,,,,,,,,,,,,,,,,i am sharing the link of this spreadsheet, and the date and time of different coloumn should be autofill when the respective department put the heading Done, in cell – Deep Kumar Jul 23 '18 at 13:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.