Skip to content

Instantly share code, notes, and snippets.

@arm5077

arm5077/code.gs

Last active May 1, 2017
Embed
What would you like to do?
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