請仔細閱讀并修改相關(guān)數(shù)據(jù)。
1、打開有重復(fù)數(shù)據(jù)的EXCEL
2、Alt+F11 打開宏編輯器
3、左邊雙擊:ThisWorkBook
4、貼入以下代碼并運行即可:
Sub 刪除重復(fù)數(shù)據(jù)()
'刪除col列的重復(fù)數(shù)據(jù)
'本例是刪除標題為sheet1的EXCEL表中A列(從A2單元格開始)的重復(fù)數(shù)據(jù)
Application.ScreenUpdating = False
'可根據(jù)實際情況修改下面三行的結(jié)尾值
Dim sheetsCaption As String: sheetsCaption = "Sheet1"
Dim Col As String: Col = "A"
Dim StartRow As Integer: StartRow = 2
'以下不需要修改
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)
Do
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 "共有" & Count_1 & "條不重復(fù)的數(shù)據(jù)"
MsgBox "刪除" & count_2 & "條重復(fù)的數(shù)據(jù)"
Application.ScreenUpdating = True
End Sub
5、按F5鍵運行即可
1、打開有重復(fù)數(shù)據(jù)的EXCEL
2、Alt+F11 打開宏編輯器
3、左邊雙擊:ThisWorkBook
4、貼入以下代碼并運行即可:
Sub 刪除重復(fù)數(shù)據(jù)()
'刪除col列的重復(fù)數(shù)據(jù)
'本例是刪除標題為sheet1的EXCEL表中A列(從A2單元格開始)的重復(fù)數(shù)據(jù)
Application.ScreenUpdating = False
'可根據(jù)實際情況修改下面三行的結(jié)尾值
Dim sheetsCaption As String: sheetsCaption = "Sheet1"
Dim Col As String: Col = "A"
Dim StartRow As Integer: StartRow = 2
'以下不需要修改
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)
Do
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 "共有" & Count_1 & "條不重復(fù)的數(shù)據(jù)"
MsgBox "刪除" & count_2 & "條重復(fù)的數(shù)據(jù)"
Application.ScreenUpdating = True
End Sub
5、按F5鍵運行即可