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
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