ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Deleting duplicate lines (https://www.excelbanter.com/excel-programming/277424-re-deleting-duplicate-lines.html)

Tom Ogilvy

Deleting duplicate lines
 
Sub DeleteDups()
Dim i as long
Dim rng as Range
set rng = Cells(rows.count,1).End(xlup)

for i = rng.row to 2 step -1
if cells(i,1).Value = cells(i-1,1).Value and _
cells(i,2).Value = cells(i-1,2).Value then
cells(i,1).EntireRow.Delete
End if
Next
Next

--
Regards,
Tom Ogilvy


Richard Leclezio wrote in message
...
What code must I write to delete duplicate rows in an
excel spreadsheet.

Eg:

Name Age
rich 25
rich 25
rich 25
linda 30
linda 30
linda 30

result:

rich 25
linda 30





All times are GMT +1. The time now is 02:56 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com