Deleting matching data

Eric Kelcher

Board Regular
Joined
May 11, 2006
Messages
130
I have a file that combines multiple years data to generate a mailing list. I want only one mailing going and I want it to be the most recent data here is sample of the file
08 license mailing list with 03 SO.xls
ABCDEFGHI
9986456865/22/2006SRAM29CHRISCONLEY2924WEISMANRDWHEATON
9996456867/23/2007SRAM104CHRISCONLEY2924WEISMANRDWHEATON
10006067371/22/2007NEEX481PAULCONLEY24WALNUTSTAPTCMAYNARD
10018276865/2/2005NVAM415STEVENCONLY41CHISSEYRD.AVON
10025041871/3/2007MAAM519MICHAELCONNER2711FORTBAKERDRSE#1WASHINGTON
10035068983/31/2003CMAM130PHILLIPCONNER11409JANUARYDR.AUSTIN
10047217085/7/2007NVAM216ERICCONNOLLY17JAFFARIANRDHAVERHILL
10055885872/8/2007NEAM165MARKCONNOLLY7WESTSTCHERRYVALLEY
10065885877/5/2005NVAM165MARKE.CONNOLLY7WESTST.CHERRYVALLEY
10076819823/22/2006GLAM42JAMESCONNOR5259E77THSTREETINDIANAPOLIS
10087429969/14/2005NVAM704JOYCECONOR162ROSLINDALEAVEBOSTON
10096618369/14/2005MWEX362DARRENCONRAD24210BROWNLANEPLAINFIELD
10106618369/16/2006NLEX762DARRENCONRAD24210BROWNLNPLAINFIELD
10112179005/31/2005MAAM118CHRISCOOKE12261D.PENDERCREEKCIR.FAIRFAX
101221790011/28/2007MAAM208CHRISCOOKE13164NEWPARKLANDDRHERNDON
CCSLIST


Where col A is a member number (this is not always entered properly or we could just use it to weed out the previous year info) Here is program I put together to do that but for some reason it does not work very well ie it leaves some that are matching numbers ??? The other issue si a member number may be assigned to another rider in future years so I sort it by name then check the member number.

Sub DuplicateRiderListprt2()
Rem for master mailing list
Range("A1:L9864").Sort Key1:=Range("b1"), Order1:=xlAscending, Key2:= _
Range("G1"), Order2:=xlAscending, Key3:=Range("F1"), Order3:=xlAscending _
, Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:= _
xlTopToBottom, DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, _
DataOption3:=xlSortNormal
Application.ScreenUpdating = False

Dim LR&, LC%, x&
With Range("A1").CurrentRegion
LR = .Rows.Count
LC = .Columns.Count
.Interior.ColorIndex = 0
End With

For x = LR - 1 To 2 Step -1
If Cells(x, 1).Value = Cells(x + 1, 1).Value Then
If Cells(x, 1).Value<> Cells(x - 1, 1).Value Then
Rows(x).Delete

End If
End If
Next x

I then have this program to check first name at an address and remove those duplicates but again it seems to remove only some from the list.

Sub DuplicateRiderList()
Rem for master mailing list
Range("A1:L9864").Sort Key1:=Range("b1"), Order1:=xlAscending, Key2:= _
Range("G1"), Order2:=xlAscending, Key3:=Range("F1"), Order3:=xlAscending _
, Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:= _
xlTopToBottom, DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, _
DataOption3:=xlSortNormal
Application.ScreenUpdating = False

Dim LR&, LC%, x&
With Range("A1").CurrentRegion
LR = .Rows.Count
LC = .Columns.Count
.Interior.ColorIndex = 0
End With

For x = LR - 1 To 2 Step -1
If Cells(x, 6).Value & Cells(x, 8).Value = Cells(x + 1, 6).Value & Cells(x + 1, 8).Value Then
If Cells(x, 6).Value & Cells(x, 8).Value<> Cells(x - 1, 6).Value & Cells(x - 1, 8).Value Then
Rows(x).Delete

End If
End If
Next x
End Sub

As an FYI this list was 11,000 entries and was pared down to 8,000 then 7,790 but I as you can see there are lots of duplicates still.

This has me really confused as it removes some but not others if it totally did not work then that would be one thing :banghead:

Oh and yes I aware that St and St. are diferent and that I will have to sort those out manually same with Ln vs Lane
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
try
Code:
Sub test()
Dim a, i As Long, ii As Integer, b(), n As Long, x
With Activesheet.UsedRange
    a = .Value
    ReDim b(1 To .Rows.Count, 1 To .Columns.Count)
    With CreateObject("Scripting.Dictionary")
        For i = 1 To UBound(a,1)
            If Not IsEmpty(a(i,1)) Then
                If Not .exists(a(i,1)) Then
                    n = n + 1
                    For ii = 1 To UBound(a,2) : b(n,ii) = a(i,ii) : Next
                    .add a(i,1), n
                Else
                    x = .item(a(i,1))
                    If b(x,2) < a(i,2) Then
                        For ii = 2 To UBound(a,2) : b(x, ii) = a(i,ii)
                    End If
                End If
            End If
        Next
    End With
    .Value = b
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,867
Messages
6,181,480
Members
453,046
Latest member
Excelvbaexpert

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top