以下代码完成
Sub 提取两列不重复数据1()
Dim d, Temp
Dim r&, r1
Dim arr, arr1
Set d = CreateObject("Scripting.Dictionary")
r = Range("A65536").End(xlUp).Row
r1 = Range("B65536").End(xlUp).Row
arr = Range("A1:A" &r).Value
arr1 = Range("B1:B" &r1).Value
For Each Temp In arr
d(Temp) = 1
Next
For Each Temp In arr1
d(Temp) = 1
Next
Range("C1").Resize(d.Count, 1) = Application.Transpose(d.keys)
End Sub
你只需要把你实际的数据列把A、B、C换成你的实际列标即可,A、B列可增减数据
Sub Sfind()Dim rng As range, srng As range
Dim dic As Variant, key As Variant
Dim i As Integer
With Sheets("Sheet2") '这里选择表格
Set srng = .[a1:c5] '这里选择要统计重复的区域
Set dic = CreateObject("Scripting.Dictionary")
For Each rng In srng
If Not IsEmpty(rng.Value) Then
If Not dic.Exists(rng.Value) Then dic.Add rng.Value, 1
End If
Next rng
key = dic.keys
.[d2].Resize(UBound(key), 1) = Application.Transpose(key)
'[d2] 这里是放结果的区域
Set srng = Nothing
Set dic = Nothing
End With
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)