I have issues with deleting rows based on date automatically. I've tried suggestions given on this link (Google Sheets - Delete Expired Rows Based On Date) but it's just removing all my entries leaving only my header
I wanted to remove the rows once the date (on column B) is expired by current date without removing new entries with new dates too
This is the code that i used based on that link:
function DeleteOldEntries() {
activeSheet = SpreadsheetApp.getActiveSheet();
var datarange = activeSheet.getDataRange();
var lastrow = datarange.getLastRow();
var values = datarange.getValues();
var currentDate = new Date();
for (i = lastrow; i >= 2; i--) {
var tempDate = values[i - 1][1];
if ((tempDate != NaN) && (tempDate <= currentDate)) {
activeSheet.deleteRow(i);
}
}
}
Any modifications on this code will be greatly appreciated!