Skip to content

Instantly share code, notes, and snippets.

@arm5077
Last active May 1, 2017 20:58
Show Gist options
  • Save arm5077/40d1fadfe10370e9f39cee6fe7719aac to your computer and use it in GitHub Desktop.
Save arm5077/40d1fadfe10370e9f39cee6fe7719aac to your computer and use it in GitHub Desktop.
Google Apps Script to update PM to-do spreadsheet when task is marked "Done."

Installation

  1. Open the spreadsheet in question.
  2. Go to Tools -> Script editor.
  3. Paste this code into the Code.gs window, and save with File -> Save.
  4. 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);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment