我有一个包含两列的工作表:日期和名称.我想删除所有完全重复的行,只留下唯一的值.
这是我的代码(不起作用):
Sub DeleteRows()
Dim rng As Range
Dim counter As Long, numRows As Long
With ActiveSheet
Set rng = ActiveSheet.Range("A1:B" & LastRowB)
End With
numRows = rng.Rows.Count
For counter = numRows To 1 Step -1
If rng.Cells(counter) Like rng.Cells(counter) - 1 Then
rng.Cells(counter).EntireRow.Delete
End If
Next
End Sub
Run Code Online (Sandbox Code Playgroud)
这是"像rng.Cells(计数器)-1"似乎是原因 - 我得到"类型不匹配".