Sub Macro1()
ActiveSheet.Range("$G$1:$G$10").RemoveDuplicates Columns:=1, Header:=xlNo
End Sub
产生:
我想保留字母顺序相同但大小写不同的单词。我将如何实现?
最佳答案
您可以使用以下代码。假定数据在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