|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Option Explicit
Sub TEST()
Dim ar, br, i&, j&, r&, k&, dic As Object, iPosCol&
Application.ScreenUpdating = False
Set dic = CreateObject("Scripting.Dictionary")
With [A5].CurrentRegion
.Offset(1).Clear
ar = .Resize(10 ^ 4)
For i = 1 To UBound(ar, 2): dic(ar(1, i)) = i: Next
r = 1
End With
For i = 1 To 2
br = Worksheets(i).[A4].CurrentRegion.Value
For k = 2 To UBound(br)
r = r + 1
For j = 1 To UBound(br, 2)
If dic.exists(br(1, j)) Then
iPosCol = dic(br(1, j))
ar(r, iPosCol) = br(k, j)
End If
Next j
Next k
Next i
[A5].Resize(r, UBound(ar, 2)) = ar
Set dic = Nothing
Application.ScreenUpdating = True
Beep
End Sub
|
|