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