Delete Duplicate rows with same cell value but.....

DaveUK

Board Regular
Joined
Jan 24, 2005
Messages
245
I am using this code to sort my list which works fine:

Code:
Sub RemoveDuplicates()

With Application
    .ScreenUpdating = False
    .Calculation = xlCalculationManual
    End With

With workbooks("Book1").Worksheets("Sheet1")

Range("A1:Q" & Range("C65536").End(xlUp).Row).Sort key1:=Range("G1"), order1:=xlAscending, key2:=Range("B1"), header:=xlYes


' ***********************************

' Need Delete Code here !!!

' ***********************************



Range("A2").Select

End With

With Application
    .ScreenUpdating = True
    .Calculation = xlCalculationAutomatic
    End With

End Sub

I need some code that will:

1, Check for duplicate cells in column C2 (as there is a header in row 1) and have a range going to the last nonempty cell in column C.

2, Delete duplicate rows BUT keep the last row as the data has been sorted by the end date and the last row containds the newest data.

Please advise.

TIA
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Code:
Dim LC As Long
Dim BR As Long
BR = Range("c65536").End(xlUp).Row
For LC = BR To 2 Step -1
If Application.WorksheetFunction.CountIf(Range("C2:C65536"), Range("C" & LC)) > 1 Then Rows(LC).Delete
Next LC
 
Upvote 0

Forum statistics

Threads
1,218,493
Messages
6,142,808
Members
450,446
Latest member
RedNectar

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