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

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

texasalynn

Well-known Member
Joined
May 19, 2002
Messages
8,458
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
 

Forum statistics

Threads
1,137,293
Messages
5,680,651
Members
419,923
Latest member
Kalthus

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
Top