Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Delete duplicate data based on date of data



'Assumptions
'Database has 6 column headers starting in A1 in Sheet1
'ORG FUNDCD DOCNO JOBNO OAC OCC
'data is sorted by JOBNO in ascending order then
'FUNDCD in ascending order
'there are maximum of 2 dates per jobno

'Initial Setup
'Need to set 3 range names as follows:

'Criteria refers to range H1:H2
'Extract refers to range J1
'Database refers to =OFFSET(Sheet1!$A$1,0,0,COUNTA(Sheet1!$A:$A),6)

'Copy Header JOBNO to H1 and J1

'Run the code below from a standard module

Sub RemoveDups()
Dim duprow As Long
Dim rngdb As Range
Dim rngCrit As Range
Dim rngExtract As Range
Dim RngDups As Range

Set rngCrit = Range("Criteria")
Set rngExtract = Range("Extract")
Set rngdb = Range("Database")


Range("Database").AdvancedFilter _
Action:=xlFilterCopy, _
CriteriaRange:=rngCrit, _
CopyToRange:=rngExtract, _
Unique:=True

Set RngDups = rngExtract.Offset(1, 0)

If RngDups.Value = "" Then
MsgBox "No Duplicates to remove"
Exit Sub
End If

Set RngDups = RngDups.Resize(rngExtract.End(xlDown).Row - 1, 1)

For Each cl In RngDups
duprow = WorksheetFunction.Match(cl, rngdb.Columns(4), 0)
rngdb.Rows(duprow).Delete
Set rngdb = Range("database")
Next

End Sub

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
using vlookup to delete duplicate data carolj Excel Worksheet Functions 4 October 7th 08 05:53 PM
How to delete duplicate data PL New Users to Excel 9 September 1st 06 03:47 AM
delete duplicate data SITCFanTN New Users to Excel 3 June 4th 06 01:42 PM
How do I delete both sets of duplicate data? Superpreciosa Excel Discussion (Misc queries) 1 July 24th 05 08:56 PM
Macro to delete duplicate data Tom Harvey Excel Programming 2 June 26th 04 01:36 AM


All times are GMT +1. The time now is 12:13 AM.

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

About Us

"It's about Microsoft Excel"