Move All Checked Rows

How to move all checked rows to another tab.
Important notes:
* Keep your math correct when iterating through the data array, deleting items from the Sheet, and deleting items from the array

Sheet (to copy from File then “Make a copy”)
https://docs.google.com/spreadsheets/d/1o-zBFV9Mqi5hngWhB9jK4xQNo4sMxrvWBemroUBMy5o/edit#gid=0

Script:
function moveChecked(){
const sh = SpreadsheetApp.getActive();
const ss = sh.getSheetByName(“New”);
const outSheet = sh.getSheetByName(“Complete”);

let data = ss.getRange(2,1,ss.getLastRow()-1,3).getValues();
let out = [];
for (let i = 0; i  < data.length; i++){
if (data[i][2] == true){
out.push(data[i]);
ss.deleteRow(i+2);
data.splice(i,1);
i–;
}
}
outSheet.getRange(outSheet.getLastRow()+1,1,out.length,3).setValues(out);
}

Connect with me:
• spencer.farris@gmail.com
• spencerfarris.me
• www.linkedin.com/in/spencer-farris/
• Twitter @FarrisSpencer
• Google Product Expert support.google.com/docs/profile/12305

Leave a Reply

Your email address will not be published. Required fields are marked *