|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Option Explicit
Sub TEST2()
Dim ar, br, cr, i&, j&, k&, r&
Application.ScreenUpdating = False
ar = Worksheets(1).[A1].CurrentRegion.Value
br = Worksheets(2).[A1].CurrentRegion
cr = ar: r = 1
For i = 2 To UBound(br)
For j = 2 To UBound(ar)
If ar(j, 1) = br(i, 1) Then
r = r + 1
For k = 1 To UBound(ar, 2)
cr(r, k) = ar(j, k)
Next k
End If
Next j
Next i
With Worksheets(3)
.Cells.Clear
.[A1].Resize(r, UBound(cr, 2)) = cr
.Activate
End With
Application.ScreenUpdating = True
Beep
End Sub
|
|