Please read and modify the relevant data carefully.
1. Open Excel with duplicate data
2, ALT+F11 open the Macro editor
3, left double click: ThisWorkBook
4, paste into the following code and run can:
Sub Delete duplicate data ()
' Delete duplicate data from Col column
' This example deletes the duplicate data in column A (starting from A2 cell) in an Excel table titled Sheet1
application.screenupdating = False
' Can modify the bottom of the following three lines according to the actual situation
Dim sheetscaption as String:sheetscaption = "Sheet1"
Dim Col as String:col = "A"
Dim StartRow as Integer:startrow = 2
' The following do not need to be modified
Dim Endrow as Integer:endrow = Sheets (sheetscaption). Range (Col & "65536"). End (Xlup). Row
Dim count_1 as Integer:count_1 = 0
Dim count_2 as Integer:count_2 = 0
Dim i as Integer:i = StartRow
With Sheets (sheetscaption)
Todo
count_1 = count_1 + 1
For j = StartRow to I-1
If. Range (Col & i) =. Range (Col & j) Then
Count_1 = Count_1-1
. Range (Col & i). Entirerow.delete
Endrow = Sheets (sheetscaption). Range (Col & "65536"). End (Xlup). Row
i = I-1
Count_2 = count_2 + 1
Exit for
End If
Next
i = i + 1
Loop While I < Endrow + 1
End With
MsgBox "Total" & count_1 & "Data not duplicated"
MsgBox "Delete" & count_2 & "Stripe duplicate data"
application.screenupdating = True
End Sub
5, press F5 key to run can