How to wirte a code in VBA (Excel 2000) to delete the repeating rows by comparing 2 columns??

Ae_Barbara

New Member
Joined
Dec 17, 2009
Messages
1
Hello !!

Currently, I 've a project concerning about Macro. I find it difficulties to write a script in Microsoft Excel 2000. So can anyone help me how to write a script in macro in order to delete a repeating
rows by comparing two columns?? But I still want to keep the first row in repeating data.. cos I feel like messy to see repeating so many time. Thats the reason why I want to keep one.

Here is an example...

Eqt Comment Date
A1 Hi 1-Dec-09
B1 Hi 2-Dec-09
B1 Hi 2-Dec-09
B1 Hi 2-Dec-09
E1 Hi 4-Dec-09
E2 Hi 5-Dec-09
C1 Hi 6-Dec-09
C1 Hi 6-Dec-09
D1 Hi 7-Dec-09
E6 Hi 12-Dec-09
F3 Hi 14-Dec-09
F3 Hi 14-Dec-09
F3 Hi 14-Dec-09
F3 Hi 14-Dec-09
G2 Hi 15-Dec-09

Note: I want to compare 'Eqt' & 'Date' columns only.. if the two columns is repeating, I just want to delete the repeating but keep one.. The main thing is I don't care the other columns. & after deleting the the repeating rows, the subsequent data must shift up.

Here is the outcome..

Eqt Comment Date
A1 Hi 1-Dec-09
B1 Hi 2-Dec-09
E1 Hi 4-Dec-09
E2 Hi 5-Dec-09
C1 Hi 6-Dec-09
D1 Hi 7-Dec-09
E6 Hi 12-Dec-09
F3 Hi 14-Dec-09
G2 Hi 15-Dec-09

PS. I hope you can solve my problem. Thanks & Regards:)
Ae
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Hello and welcome to MrExcel.

Try this with a copy of your sheet

Code:
Sub DelDups()
Dim LR As Long, i As Long, j As Integer
LR = Cells(Rows.Count, "A").End(xlUp).Row
For i = LR To 3 Step -1
    With Range("A" & i)
        If .Value = .Offset(-1).Value And .Offset(, 2).Value = .Offset(-1, 2).Value Then Rows(i).Delete
    End With
Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,881
Messages
6,122,074
Members
449,064
Latest member
MattDRT

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