The first row has a column heading: First Name, Last Name, Email, Grade, Date We have instances where people need to re-take tests and therefore will have another entry into the spreadsheet, what we are looking for, is a way that if someone re-takes the test and then adds their new data into the spreadsheet, we can automatically remove their old information
So, I have made some progress, this script removes duplicate rows, but exactly duplicate, so I need to somehow edit it to only look at the first 2 columns and then delete the oldest entry based on the Date column:
function removeDuplicates() {
var sheet = SpreadsheetApp.getActiveSheet();
var data = sheet.getDataRange().getValues();
var newData = [];
for (var i in data) {
var row = data[i];
var duplicate = false;
for (var j in newData) {
if (row.join() == newData[j].join()) {
duplicate = true;
}
}
if (!duplicate) {
newData.push(row);
}
}
sheet.clearContents();
sheet.getRange(1, 1, newData.length, newData[0].length).setValues(newData);
}