PC Review


Reply
Thread Tools Rate Thread

delete duplicate rows, keep latest date and time group

 
 
jaydywan@gmail.com
Guest
Posts: n/a
 
      12th Jul 2007
Trying to get rid of duplicate rows, and keep only the latest date/
time group. Currently it gives me the earliest date/time group. I
have researched past posts, but they all seem to keep the earliest
date.

What do I need to change in the code below, or possibly you can
suggest a different way of doing it. Thanks.


Dim Col As Integer
Dim r As Long
Dim C As Range
Dim N As Long
Dim V As Variant
Dim Rng As Range

Range("A1").Select

Application.Calculation = xlCalculationManual
Col = ActiveCell.Column

If Selection.Rows.Count > 1 Then
Set Rng = Selection
Else: Set Rng = ActiveSheet.UsedRange.Rows
End If

N = 0
For r = Rng.Rows.Count To 1 Step -1
V = Rng.Cells(r, 1).Value
If Application.WorksheetFunction.CountIf _
(Rng.Columns(1), V) > 1 Then
Rng.Rows(r).EntireRow.Delete
N = N + 1
End If
Next r

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Filter Duplicate Records keeping record with latest date LROCCO Microsoft Excel Discussion 2 13th Nov 2009 09:21 AM
How to find latest date/time in grouped rows Dorian Microsoft Access Queries 5 10th Jan 2009 04:23 PM
Delete Duplicate Rows, by Date field DTTODGG Microsoft Excel Programming 4 4th Feb 2008 11:38 PM
Date/Time datatype in Access 2003 affects date/time duplicate quer =?Utf-8?B?VGltIFQ=?= Microsoft Access Queries 4 27th Jun 2005 02:20 AM
latest date per group within 1 table =?Utf-8?B?UEFU?= Microsoft Access Getting Started 1 25th Apr 2005 01:19 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:26 PM.