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:


Order Id
Total----$24,893.66305$81.62
36051480
----$817.381$817.38
36051480$0.00---$817.381$817.38
36051480$0.00$817.38NULL$0.00$817.381$817.38
36053154
----$749.501$749.50
36053154$0.00---$749.501$749.50
36053154$0.00$749.50NULL$0.00$749.501$749.50

<tbody>
</tbody>
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
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,215,463
Messages
6,124,965
Members
449,201
Latest member
Jamil ahmed

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