- Open the spreadsheet in question.
- Go to Tools -> Script editor.
- Paste this code into the
Code.gs
window, and save with File -> Save. - Return to your spreadsheet and toggle a task to "Done." It shoulddddd work!
(Mostly stolen from here.)
function onEdit(e) { | |
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet(); | |
var sheet = e.source.getActiveSheet(); | |
var cell = e.source.getActiveRange(); | |
if( sheet.getName() == 'Tasks' && cell.getColumn() == 4 && cell.getValue() == 'Done'){ | |
var row = cell.getRow(); | |
var targetSheet = spreadsheet.getSheetByName("Tasks - done"); | |
var targetRow = targetSheet.getRange(targetSheet.getLastRow() + 1, 1); | |
// 15 is a bit of a magic number but I doubt you'll ever pull more rows than that? | |
sheet.getRange(row, 1, 1, 15).moveTo(targetRow); | |
sheet.deleteRow(row); | |
} | |
} |