|
代码如下。。。
Sub test()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
t = Timer
Dim wb As Workbook, sht As Worksheet, sh As Worksheet
Set wb = ThisWorkbook
Set sht = wb.Sheets("表1")
Set sh = wb.Sheets("表2")
arr = sht.[a1].CurrentRegion
Set d = CreateObject("scripting.dictionary")
For i = 1 To UBound(arr)
s = arr(i, 1)
d(s) = Application.Index(arr, i)
Next
n = 0
ReDim brr(1 To 10 ^ 6, 1 To UBound(arr, 2))
For Each Item In d.items
n = n + 1
For j = 1 To UBound(Item)
brr(n, j) = Item(j)
Next
Next
arr = sh.[a1].CurrentRegion
Set dic = CreateObject("scripting.dictionary")
For i = 2 To UBound(arr)
s = arr(i, 1)
If Not d.exists(s) Then
dic(s) = Application.Index(arr, i)
End If
Next
With wb.Sheets("表3")
.Cells.ClearContents
For Each Item In dic.items
n = n + 1
For j = 1 To UBound(Item)
brr(n, j) = Item(j)
Next
Next
.Columns(1).NumberFormat = "@"
.[a1].Resize(n, UBound(brr, 2)) = brr
End With
Set d = Nothing
Set dic = Nothing
Application.ScreenUpdating = True
Application.DisplayAlerts = True
MsgBox "共耗时:" & Format(Timer - t, "0.0000") & " 秒!!!", 64
End Sub
|
评分
-
1
查看全部评分
-
|