Hi guy's i'm trying to create a to-do list at google sheets and i'm using a template from google
and i found a script at youtube to clear the done tasks and it's working.
But, i need to do one more thing, i need to move the completed tasks to another sheet and i tried so many scripts and i can't get it to work.
My main sheet is "Tarefas" and the completed sheet is "Finalizadas"
my sheet is: https://docs.google.com/spreadsheets/d/1DZgXfHoQ3hwbBCPpLAOoQ8Jd0u5OMeQpX_OWWlgpa2I/edit?usp=sharing
and the code to clear the rows is:
function ClearRecords()
{
// DECLARE ACTIVE SHEETS
var ss = SpreadsheetApp.getActiveSpreadsheet();
// DECLARE SHEET
var todoSheet = ss.getSheetByName("Tarefas");
// LAST ROW ON TO DO SHEET
var lastRowToDo = todoSheet.getLastRow();
// GET LAST TASK
for(var x = 4; x <= lastRowToDo; x++)
{
if(todoSheet.getRange(x,3).isBlank() == true)
{
var lastTaskRow = x - 1;
}
}
for(var i = 4; i <= lastTaskRow; i++)
{
if(todoSheet.getRange(i, 1).getValue() == true)
{
todoSheet.getRange("B" + i + ":C" + i).setValues([["",""]]);
todoSheet.getRange(i, 1).setValue(false);
}
}
SpreadsheetApp.flush();
var OpenRows = [];
for(var i = 4; i <= lastTaskRow; i++)
{
if(todoSheet.getRange(i,3).isBlank() == true)
{
OpenRows.push(i);
}
else
{
if(OpenRows.length > 0)
{
var nextRow = OpenRows.shift();
var values = todoSheet.getRange("B" + i + ":C" + i).getValues();
todoSheet.getRange("B" + nextRow + ":C" + nextRow).setValues(values);
todoSheet.getRange("B" + i + ":C" + i).setValues([["",""]]);
OpenRows.push(i);
}
}
}
}