title: Transferring (Cut and Paste) Rows from One sheet to another based on a cell value dependent on another cell in Google Sheets
body: <p>So I have a Google Sheet which has two sheets 'Enquiry' and 'Follow up'. I want a script that automatically transfers rows whose Zth column contains the word 'Complete' from the sheet 'Enquiry' to the 'Follow up' sheet. By transfer I mean rows should be deleted from 'Enquiry' and pasted in Follow up'. Also the Zth column in 'Enquiry' is dependent on the value of the column U of 'Enquiry'. I've put a condition in Z that if U = condition, then Z="Complete".</p>
  
  <p>I want this to be done automatically and I don't have to run the function again and again.</p>
  
  <p>So basically how it would work is,</p>
  
  <p>Column U is updated in 'Enquiry'. If condition matches, column Z in 'Enquiry would become "Complete". Then this row should be deleted from here and pasted in the sheet 'Follow up'.</p>
  
  <p>I've been using this code:</p>
  
  <pre><code>function onEdit() {
  var sheetNameToWatch = "ENQUIRY";
  var columnNumberToWatch = 26; 
  var valueToWatch = "Complete";
  var sheetNameToMoveTheRowTo = "Follow up";
  
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = SpreadsheetApp.getActiveSheet();
  var range = sheet.getActiveCell();
  
  
  if (sheet.getName() == sheetNameToWatch &amp;&amp; range.getColumn() == columnNumberToWatch &amp;&amp; range.getValue() == valueToWatch) {
  
  var targetSheet = ss.getSheetByName(sheetNameToMoveTheRowTo);
  var targetRange = targetSheet.getRange(targetSheet.getLastRow() + 1, 1);
  sheet.getRange(range.getRow(), 1, 1, sheet.getLastColumn()).moveTo(targetRange);
  sheet.deleteRow(range.getRow());
  }
  }
  </code></pre>
  
  <p>But this only works when I type in Complete in the column Z of Enquiry sheet and enter. Not how I'd like it to work. Please help</p>