1

I am using this function to automatically move a row to a secondary sheet when a set value is entered.

function onEdit() {
  var sheetNameToWatch = "Tracker";

  var columnNumberToWatch = 4; 
  var valueToWatch = "YES";
  var sheetNameToMoveTheRowTo = "30Day";

  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = SpreadsheetApp.getActiveSheet();
  var range = sheet.getActiveCell();


  if (sheet.getName() == sheetNameToWatch && range.getColumn() == columnNumberToWatch && range.getValue() == valueToWatch) {

    var targetSheet = ss.getSheetByName(sheetNameToMoveTheRowTo);
    var targetRange = targetSheet.getRange(targetSheet.getLastRow() + 1, 1);
    sheet.getRange(range.getRow(), 1, 1, sheet.getLastColumn()).copyTo(targetRange);
    sheet.deleteRow(range.getRow());
  }
}

What I want is to have an Automatic timestamp show up when it gets moved over. The problem is that all the functions I have found require you to go to the second sheet and manually change something in order for it to trigger. I want to trigger as the above script move the row over. Any help would save me a lot of time and beating my head against the wall.

Your Answer

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

Browse other questions tagged or ask your own question.