title: Move rows from one sheet to another
body: <p>I need to move rows from a pending sheet to an archive sheet based on the background color. I found a script and managed to edit it to adapt to my needs except for a few things I can't figure out (i don't know how to code except for some basic school stuff). What I worked to is this:</p>
  
  <pre><code>function onEdit(event) {
    // assumes source data in sheet named Pendientes
    // target sheet of copy to named Enviados
    // getColumn with color is currently set to colu 3 or C
    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var s = event.source.getActiveSheet();
    var r = event.source.getActiveRange();
  
    if(s.getName() == "Pendientes" &amp;&amp; r.getColumn() == 3 &amp;&amp; r.getBackground() == "#00ff00") {
      var row = r.getRow();
      var numColumns = s.getLastColumn();
      var targetSheet = ss.getSheetByName("Enviados");
      var target = targetSheet.getRange(targetSheet.getLastRow() + 1, 1);
      s.getRange(row, 1, 1, numColumns).copyTo(target, {contentsOnly:true});
      s.deleteRow(row);
      targetSheet.getRange(targetSheet.getLastRow(), 7).setValue(new Date()).setNumberFormat("dd-mm-yy");
      targetSheet.insertRowAfter(targetSheet.getLastRow())
    }
  }
  </code></pre>
  
  <p>​What I can't figure out:<br>
  The script originaly runs when you edit the content of the cell (the background color doesn't count, took me a while to figure out why it wasn't working) and moved the rows when a value changed from false to true.<br>
  What I would like to do is to change the trigger to a custom menu I built, so when you click on it it looks at all the rows, finds the cells with green background and moves them to the archive. Because the original script uses an event which triggers the script every time an edit is made and analyses that single moment I'm not sure how to do it.<br>
  I'd also like if possible for the cells to transfer in order based on column 2, so first it looks for green cells in column 3 with OptionA in column 2 and moves it, then with OptionB, and so on.   </p>
  
  <p>I'm also not sure if the line I added to insert 1 row for each row moved will work when moving rows masively, meaning if it moves 10 rows will it insert 10 new rows or 1 single row.   </p>
  
  <p>I made a sample sheet in which i've been experimenting:<br>
  <a href="https://docs.google.com/spreadsheets/d/1tzGnuT107u1msx6BchZAEHE7NbsxIVcqXasGilQeTbA/edit?usp=sharing" rel="nofollow noreferrer">https://docs.google.com/spreadsheets/d/1tzGnuT107u1msx6BchZAEHE7NbsxIVcqXasGilQeTbA/edit?usp=sharing</a></p>
  
  <p>Thanks!</p>