Remove duplicated data and inform user how many data have been removed using macro

mike00

New Member
Joined
Jan 5, 2018
Messages
5
How can I create a macro to remove from the dataset duplicated data? If there are two versions, one of them is removed entirely, leaving just a single version in the dataset. I have to inform the user how many data have been removed in total. FYI, I have over 50,000 data. Can someone help me to amend the code, it doesn't seem working.

Sub sbFindDuplicatesInColumn_E()

Dim lastRow As Long
Dim matchFoundIndex As Long
Dim x As Long
Dim counter As Integer

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.DisplayStatusBar = False
ActiveSheet.DisplayPageBreaks = False


lastRow = Range("E57249").End(xlUp).Row
For x = 1 To lastRow
car = Cells(9 + x, 5).Value
If Cells(9 + x, 5) <> "" Then
matchFoundIndex = WorksheetFunction.Match(Cells(9 + x, 5), Range("E10:E" & lastRow), 0)
If 9 + x <> matchFoundIndex Then

counter = counter + 1
Sheets("2016 data").Cells(9 + x, 5).Delete xlShiftUp
End If
End If
Next x

MsgBox "the number of cars that have been reomoved is " & counter
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
Application.DisplayStatusBar = True
ActiveSheet.DisplayPageBreaks = True

End Sub
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

Forum statistics

Threads
1,215,403
Messages
6,124,710
Members
449,182
Latest member
mrlanc20

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