Delete duplicate rows macro needed - a little complicated

WebAnalytics

New Member
Joined
Aug 20, 2012
Messages
4
Please see below: need a macro that will delete the first two entire rows of duplicate order id's and keep the third

Any help? :confused:


[TABLE="width: 1063"]
<tbody>[TR]
[TD]Order Id[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Total[/TD]
[TD]-[/TD]
[TD]-[/TD]
[TD]-[/TD]
[TD]-[/TD]
[TD="align: right"]$24,893.66[/TD]
[TD="align: right"]305[/TD]
[TD="align: right"]$81.62[/TD]
[/TR]
[TR]
[TD="align: right"]36051480
[/TD]
[TD]-[/TD]
[TD]-[/TD]
[TD]-[/TD]
[TD]-[/TD]
[TD="align: right"]$817.38[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]$817.38[/TD]
[/TR]
[TR]
[TD="align: right"]36051480[/TD]
[TD="align: right"]$0.00[/TD]
[TD]-[/TD]
[TD]-[/TD]
[TD]-[/TD]
[TD="align: right"]$817.38[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]$817.38[/TD]
[/TR]
[TR]
[TD="align: right"]36051480[/TD]
[TD="align: right"]$0.00[/TD]
[TD="align: right"]$817.38[/TD]
[TD]NULL[/TD]
[TD="align: right"]$0.00[/TD]
[TD="align: right"]$817.38[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]$817.38[/TD]
[/TR]
[TR]
[TD="align: right"]36053154
[/TD]
[TD]-[/TD]
[TD]-[/TD]
[TD]-[/TD]
[TD]-[/TD]
[TD="align: right"]$749.50[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]$749.50[/TD]
[/TR]
[TR]
[TD="align: right"]36053154[/TD]
[TD="align: right"]$0.00[/TD]
[TD]-[/TD]
[TD]-[/TD]
[TD]-[/TD]
[TD="align: right"]$749.50[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]$749.50[/TD]
[/TR]
[TR]
[TD="align: right"]36053154[/TD]
[TD="align: right"]$0.00[/TD]
[TD="align: right"]$749.50[/TD]
[TD]NULL[/TD]
[TD="align: right"]$0.00[/TD]
[TD="align: right"]$749.50[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]$749.50[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Just a few questions:

1. Are there always 3 entries for each ORDER ID, I mean a set of duplicates and 1 unique entry
2. Do the cells with dashes "-" only have values on the unique entry's line
 
Upvote 0
try this
Code:
Sub DeleteDups()
Dim i, LR, RCnt As Long
LR = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row
For i = LR To 2 Step -1
    RCnt = WorksheetFunction.CountIf(Columns("A"), Cells(i, "A"))
    RCnt2 = WorksheetFunction.CountIf(Columns("F"), Cells(i, "F"))
        If (RCnt > 1 And Cells(i, "C") = "-") And _
            (RCnt2 > 1 And Cells(i, "E") = "-") Then
            Rows(i).Delete
        End If
Next i
MsgBox "Done"
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,971
Members
452,371
Latest member
Frana

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