Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default preserve last row while looking through a column of duplicate information

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default preserve last row while looking through a column of duplicate information

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

Marcusdmc wrote:
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


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
Preserve Column Widths in Table when Reordering Columns Nick Excel Discussion (Misc queries) 0 August 26th 09 11:46 PM
Duplicate information Lloyd Excel Worksheet Functions 1 November 24th 06 10:49 AM
Duplicate Data -Adding information to another column in row & dele Jacky D. Excel Discussion (Misc queries) 3 July 27th 05 01:00 AM
Duplicate information Stephanie Excel Discussion (Misc queries) 1 March 31st 05 10:44 PM
Preserve a range information Nicke[_16_] Excel Programming 1 October 21st 04 08:51 AM


All times are GMT +1. The time now is 01:26 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"