I have a Google sheet with multiple sheets to display a student's incomplete assignments. The students write a student number in cell A5 to display their data on the "input" sheet. I want cell A5 to be zero when the student opens the file. I tried using the code below with the trigger "on open" but it is too slow to keep students from seeing other students' data. Is there a way to set A5 to zero on closing? The "input" sheet should always be the active sheet since it is the only sheet that isn't hidden.
function myFunction() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var range = sheet.getRange("A5");
range.clearContent();
}