Deleting Duplicate Rows

herpasymplex10

Board Regular
Joined
May 26, 2005
Messages
224
Is there a way to write a code that would look at data in column B
THEN
look at all previous worksheets in a workbook under Column B for that same data

If it finds a duplicate on a previous worksheet,
it deletes the row
the duplicate is in
on the latest worksheet?

I have worksheets that are in date order from left to right
the one all the way to the right being the most recent date
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
this is not tested, so make a backup before you run this code

Code:
Sub SDupDel()
    FirstWS = 1
    LastWS = Worksheets.Count
Worksheets(LastWS).Activate
LI = Range("B65536").End(xlUp).Row
For df = 1 To LI
    di = Cells(df, 2).Value
    For i = FirstWS To LastWS - 1
        Worksheets(i).Activate
        LR = Range("D65536").End(xlUp).Row
        If Cells(i, 2).Value = di Then
        Cells(2, 2).EntireRow.Delete
        End If
    Next i
Next df

End Sub
 
Upvote 0

Forum statistics

Threads
1,224,975
Messages
6,182,109
Members
453,088
Latest member
Chaoxite

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