![]() |
Deleting Rows based on the duplicate contents of a single cell
I have a data base of addresses for homes. The data is repeated in many
cases based on previous listings or sales, and I want to only save the latest record, deleting the earlier ones. I've sorted the data based on date, and would like to delete row( i ) if the text in Cell(i,1) is the same as the text in Cell(i-1,1) I've made a few attempts, but have had no joy. This seems like a pretty trivial exercise - I only need what would be in the if...end if portion. Any suggstions would be appreciated Thanks, Jim |
Deleting Rows based on the duplicate contents of a single cell
Deleting rows should work from the bottom up.
Sub delRw() Dim lstRw As Long, Dim ws As Worksheet Set ws = ActiveSheet lstRw = ws.Cells(Rows.Count, 1).End(xlUp).Row For i = lstRw To 2 Step -1 If ws.Cells(i, 1).Value = ws.Cells(i-1, 1).Value Then ws.Cells(i, 1).EntireRow.Delete End If Next End Sub "Jim Berglund" wrote in message ... I have a data base of addresses for homes. The data is repeated in many cases based on previous listings or sales, and I want to only save the latest record, deleting the earlier ones. I've sorted the data based on date, and would like to delete row( i ) if the text in Cell(i,1) is the same as the text in Cell(i-1,1) I've made a few attempts, but have had no joy. This seems like a pretty trivial exercise - I only need what would be in the if...end if portion. Any suggstions would be appreciated Thanks, Jim |
All times are GMT +1. The time now is 08:46 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com