Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Duplicate Rows Based On Cell Value? [email protected] Excel Programming 2 June 20th 08 05:29 PM
Select & deleting all rows based on the contents of a cell in the Dwoeltje Excel Programming 7 October 1st 07 01:46 PM
Macro Help for Deleting Blank Rows & Clearing Cell Contents ksp Excel Programming 2 January 13th 06 05:25 AM
Deleting rows dependent upon cell contents daedalus1 Excel Programming 4 October 25th 05 02:05 PM
Deleting rows based on a cell value JPriest Excel Worksheet Functions 3 August 12th 05 05:44 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"