发现了很多涉及在两列中查找重复项的问题:
即 MS Excel如何创建一个宏来查找重复项并突出显示它们?和excel标记重复值
但是,我正在尝试调整代码以用于在一列中查找重复项.例如,这是一个数据集:
第1栏
Foo
Bar
23
23
12
foo
Bar
bart
这就是我现在正在使用的:
Function warnDupes()
Dim lastRow As Long
Dim dict As Object
' Let Col be the column which warnDupes operates on.
Dim Col As String
Col = "A"
Set dict = CreateObject("scripting.dictionary")
lastRow = range(Col & Rows.Count).End(xlUp).Row
On Error Resume Next
For i = lastRow To 1 Step -1
If dict.Exists(range(Col & i).value) = True Then
'range("Y" & i).EntireRow.Delete
MsgBox ("Hmm...Seems to be a …Run Code Online (Sandbox Code Playgroud)