|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub TEST6()
Dim arr, vResult, i&, R&, dic As Object
Application.ScreenUpdating = False
Set dic = CreateObject("Scripting.Dictionary")
arr = [A1].CurrentRegion: R = UBound(arr)
For i = 2 To UBound(arr)
dic(arr(i, 1)) = ""
Next i
vResult = Application.Transpose(arr)
arr = Sheets(2).[A1].CurrentRegion
For i = 2 To UBound(arr)
If Not dic.Exists(arr(i, 1)) Then
R = R + 1
ReDim Preserve vResult(1 To UBound(vResult), 1 To R)
vResult(1, R) = arr(i, 1)
vResult(2, R) = arr(i, 2)
End If
Next i
Columns(1).NumberFormatLocal = "@"
[A1].Resize(UBound(vResult, 2), UBound(vResult)) = Application.Transpose(vResult)
Set dic = Nothing
Application.ScreenUpdating = True
Beep
End Sub |
|