title: Moving more rows then selected
body: <p>I have this app script that is supposed to move a row if a checkbox to marked or unmarked (to another sheet). I know there is definitely some real cleanup I need todo but when I read thru it all seems like it should work.</p>
  <p>Currently if I check a box it moves that row then moves the last row also. Any pointers would help.</p>
  <p>I am thinking about re-doing this proper instead of a bunch of if statements. But I do need it to work in the meantime.</p>
  <blockquote>
  <p>IF: Sheet name XA and column Y = TRUE move to sheet Xb and delete Row
  This is done for 4 possible check boxes</p>
  </blockquote>
  <pre><code>
  
  function onEdit(e) {
    var sh = e.range.getSheet();
    if(sh.getName() == &quot;Working on&quot; &amp;&amp; e.range.columnStart == 9 &amp;&amp; e.value == &quot;TRUE&quot;) {
      var numColumns = sh.getLastColumn();
      var tsh = e.source.getSheetByName(&quot;Submited Routes&quot;);
      var trg = tsh.getRange(tsh.getLastRow() + 1, 1);
      sh.getRange(e.range.rowStart, 1, 1, numColumns).moveTo(trg);
      sh.deleteRow(e.range.rowStart);
    } else if(sh.getName() == &quot;Submited Routes&quot; &amp;&amp; e.range.columnStart == 9 &amp;&amp; e.value == &quot;FALSE&quot;) {
      var numColumns = sh.getLastColumn();
      var tsh = e.source.getSheetByName(&quot;Working on&quot;);
      var trg = tsh.getRange(tsh.getLastRow() + 1, 1);
      sh.getRange(e.range.rowStart, 1, 1, numColumns).moveTo(trg);
      sh.deleteRow(e.range.rowStart);
    }
    if(sh.getName() == &quot;Working on&quot; &amp;&amp; e.range.columnStart == 11 &amp;&amp; e.value == &quot;TRUE&quot;) {
      var numColumns = sh.getLastColumn();
      var tsh = e.source.getSheetByName(&quot;Missed&quot;);
      var trg = tsh.getRange(tsh.getLastRow() + 1, 1);
      sh.getRange(e.range.rowStart, 1, 1, numColumns).moveTo(trg);
      sh.deleteRow(e.range.rowStart);
    } else if(sh.getName() == &quot;Missed&quot; &amp;&amp; e.range.columnStart == 11 &amp;&amp; e.value == &quot;FALSE&quot;) {
      var numColumns = sh.getLastColumn();
      var tsh = e.source.getSheetByName(&quot;Working on&quot;);
      var trg = tsh.getRange(tsh.getLastRow() + 1, 1);
      sh.getRange(e.range.rowStart, 1, 1, numColumns).moveTo(trg);
      sh.deleteRow(e.range.rowStart);
    }
  
  
    // NOT AWARDED AUTOMATED MOVE AND DELTE
    if(sh.getName() == &quot;Submited Routes&quot; &amp;&amp; e.range.columnStart == 15 &amp;&amp; e.value == &quot;TRUE&quot;) {
      var numColumns = sh.getLastColumn();
      var tsh = e.source.getSheetByName(&quot;Not awarded&quot;);
      var trg = tsh.getRange(tsh.getLastRow() + 1, 1);
      sh.getRange(e.range.rowStart, 1, 1, numColumns).moveTo(trg);
      sh.deleteRow(e.range.rowStart);
    } else if(sh.getName() == &quot;Not awarded&quot; &amp;&amp; e.range.columnStart == 15 &amp;&amp; e.value == &quot;FALSE&quot;) {
      var numColumns = sh.getLastColumn();
      var tsh = e.source.getSheetByName(&quot;Submited Routes&quot;);
      var trg = tsh.getRange(tsh.getLastRow() + 1, 1);
      sh.getRange(e.range.rowStart, 1, 1, numColumns).moveTo(trg);
      sh.deleteRow(e.range.rowStart);
    }
    if(sh.getName() == &quot;Working on&quot; &amp;&amp; e.range.columnStart == 15 &amp;&amp; e.value == &quot;TRUE&quot;) {
      var numColumns = sh.getLastColumn();
      var tsh = e.source.getSheetByName(&quot;Not awarded&quot;);
      var trg = tsh.getRange(tsh.getLastRow() + 1, 1);
      sh.getRange(e.range.rowStart, 1, 1, numColumns).moveTo(trg);
      sh.deleteRow(e.range.rowStart);
    } else if(sh.getName() == &quot;Not awarded&quot; &amp;&amp; e.range.columnStart == 15 &amp;&amp; e.value == &quot;FALSE&quot;) {
      var numColumns = sh.getLastColumn();
      var tsh = e.source.getSheetByName(&quot;Working on&quot;);
      var trg = tsh.getRange(tsh.getLastRow() + 1, 1);
      sh.getRange(e.range.rowStart, 1, 1, numColumns).moveTo(trg);
      sh.deleteRow(e.range.rowStart);
    }
  }
  </code></pre>