答案 0 :(得分:3)
您可以使用以下代码。假设数据在A1到A7的范围内,对于不同的范围,您可以修改代码。
Dim oDic As Object, vData As Variant, r As Long
Set oDic = CreateObject("Scripting.Dictionary")
With Range("A1:A7")
vData = .Value
.ClearContents
End With
With oDic
.comparemode = 0
For r = 1 To UBound(vData, 1)
If Not IsEmpty(vData(r, 1)) And Not .Exists(vData(r, 1)) Then
.Add vData(r, 1), Nothing
End If
Next r
Range("A1").Resize(.Count) = Application.Transpose(.keys)
End With
答案 1 :(得分:2)
这是一种可能适合您的方法。 (它显然有一些粗略的编码元素,但我认为你得到了图片,可以根据需要修复任何东西):
Sub RespectCase()
Dim rSearch As Range, cel As Range, rFound As Range
Set rSearch = Range("G1:G10")
Set rFound = Range("J1:J10")
For Each cel In rSearch
Dim rMatch As Range
Set rMatch = rFound.Find(cel, LookAt:=xlWhole, MatchCase:=True)
If rMatch Is Nothing Then
Range("J10").End(xlUp).Offset(1).Value = cel
End If
Next
End Sub