Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function moveCompletedTasks() {
- // Define the active sheet and the sheet for completed tasks
- var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
- var completedSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Completed Tasks");
- // Get the data from the active sheet
- var range = sheet.getDataRange();
- var values = range.getValues();
- // Loop through the rows in reverse to avoid skipping rows after deletion
- for (var i = values.length - 1; i >= 1; i--) {
- if (values[i][6] === 'Completed') {
- // Append the completed task row to the "Completed Tasks" sheet
- completedSheet.appendRow(values[i]);
- // Delete the row from the original sheet
- sheet.deleteRow(i + 1); // Rows are 1-indexed in Sheets
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement