0

I'm using a function that I found on another thread here on stackexchange, but I would like to limit the function to only work in 1 specific sheet at the time.

I have old sheets with history that is overwritten if there is a change in those sheets.

The function I use:

function onEdit() {
  var s = SpreadsheetApp.getActiveSheet();
  var r = s.getActiveCell();
  if( r.getColumn() != 2 ) { //checks the column
    var row = r.getRow();
    var time = new Date();
    time = Utilities.formatDate(time, "GMT+02:00", "dd.MM.yyyy, HH:mm");
    SpreadsheetApp.getActiveSheet().getRange('T' + row.toString()).setValue(time);
  };
 };

I'm guessing I have to add the name of the sheet within getRange?

1

Found it out myself for those needing help.

Use getSheetByName(Name)

function onEdit() {
  var s = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('UPDATE');
  var r = s.getActiveCell();
  if( r.getColumn() != 2 ) { //checks the column
    var row = r.getRow();
    var time = new Date();
    time = Utilities.formatDate(time, "GMT+02:00", "dd.MM.yyyy, HH:mm");
    SpreadsheetApp.getActiveSpreadsheet().getSheetByName('UPDATE').getRange('T' + row.toString()).setValue(time);
  };
 }; 

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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