Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / September 2007

Tip: Looking for answers? Try searching our database.

preserve last row while looking through a column of duplicate information

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Marcusdmc - 25 Sep 2007 19:56 GMT
Is there a way to instead of deleting the extra rows after the first
duplicate is found, to delete all but the last one of the duplicates?
As in, keep the last duplicate, discard the ones above it.  I know the
reverse can be done... Thanks for any direction!

-Marcus
JW - 25 Sep 2007 20:32 GMT
One way:
This will cycle through all cells in column A, starting at the bottom,
and delete the entire row above it if it is a match.
Sub delDups()
   For i = Cells(Rows.Count, 1).End(xlUp).Row To 2 Step -1
       Do Until Cells(i, 1).Offset(-1, 0).Text <> Cells(i, 1).Text
           Cells(i, 1).Offset(-1, 0).EntireRow.Delete
       Loop
   Next i
End Sub

> Is there a way to instead of deleting the extra rows after the first
> duplicate is found, to delete all but the last one of the duplicates?
> As in, keep the last duplicate, discard the ones above it.  I know the
> reverse can be done... Thanks for any direction!
>
> -Marcus
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.