Skip to content

Instantly share code, notes, and snippets.

@techtide
Last active January 13, 2019 22:38
Show Gist options
  • Save techtide/9b699eb2218c6d3bd89c9114be195efe to your computer and use it in GitHub Desktop.
Save techtide/9b699eb2218c6d3bd89c9114be195efe to your computer and use it in GitHub Desktop.
// Script by Arman B. for ASL's SLD department.
// 6 sign-ups per a block, multiplied by 4 blocks per a day, is about 50 - combined with extra sign-ups, so the range should really be up to 50.
function onEdit() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var range = sheet.getRange("A2:G100");
var data = sheet.getDataRange().getValues();
range.sort([{column: 4, ascending: true}]);
var todayDate = new Date();
// Make sure that column 3 is always formatted as a date.
for(var I = 1; I < 100; I++) {
if(data[3][I].valueOf() < todayDate.valueOf()) {
deleteRow(I);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment