Home > Mobile >  Remove duplicates based on one column and keep latest entry in google sheets
Remove duplicates based on one column and keep latest entry in google sheets

Time:02-11

I was working on some automation and wanted to remove the duplicate rows in my google sheet by comparing it on basis of 3rd column. I found one code which is working flawlessly but it does not remove the old entry in sheet, it removes the latest one. I wanted to keep the latest one from the duplicates.

This is the code which I found for appscript by enter image description here

After:

enter image description here

Update

If there will some glitches it makes sense to add the command flush() after every deleteRow(). The last line of the code should be like this:

  // remove rows by the indexes
  duplicates.reverse().forEach(x => { sh.deleteRow(x); SpreadsheetApp.flush() });
  • Related