Sorry for not giving sample data.
Sam, your answer works. Thank you very much. 😀
I used the first script since the last row is always the highest date.
I did have to add a RowID.
If anyone is interested, I attached a spreadsheet containing Sheet1 with raw data and Sheet2 with results.
Thanks to all who replied!