excel从行中删除重复值

时间:2017-01-24 10:51:41

标签: duplicates rows

我需要从多行中删除多行的重复值。 例如:

collection.size

我只需要

597 2733    2710    2710    2687    2687    2687    2687
597 2710    2688    2688    2687    2687    2687    2687
597 2688    2713    2713    2734    2734    2734    2734

有什么建议怎么办?

2 个答案:

答案 0 :(得分:0)

您可以将数据保存到一列并转到Excel中的“数据”选项卡,您将找到名为“删除重复”的按钮

希望有所帮助

答案 1 :(得分:0)

需要修改此代码/然后可以删除/只需标记

Sub DuplicateValuesFromRow()
'Declare All Variables.
Dim myCell As Range
Dim myRow As Integer
Dim myRange As Range
Dim myCol As Integer
Dim i As Integer
'Count Number of Rows and Columns
myRow = Range(Cells(1, 1), Cells(1, 1).End(xlDown)).Count
myCol = Range(Cells(1, 1), Cells(1, 1).End(xlToRight)).Count
'Loop Each Row To Check Duplicate Values and Highlight cells.
For i = 2 To myRow
Set myRange = Range(Cells(i, 2), Cells(i, myCol))
For Each myCell In myRange
If WorksheetFunction.CountIf(myRange, myCell.Value) > 1 Then
myCell.Interior.ColorIndex = 3
End If
Next
Next
End Sub