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

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

Oorang

Well-known Member
Joined
Mar 4, 2005
Messages
2,071
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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,620
Messages
5,832,734
Members
430,160
Latest member
a_majda

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