Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Duplicate Rows Based On Cell Value? | Excel Programming | |||
Select & deleting all rows based on the contents of a cell in the | Excel Programming | |||
Macro Help for Deleting Blank Rows & Clearing Cell Contents | Excel Programming | |||
Deleting rows dependent upon cell contents | Excel Programming | |||
Deleting rows based on a cell value | Excel Worksheet Functions |