
Option Explicit
Sub abc()
Dim a, d, i, j
a = [g2].Resize([g1].End(xlDown).Row - 1).Value
Set d = CreateObject("scripting.dictionary")
For i = 1 To UBound(a)
d(a(i, 1)) = i
Next
a = [a1].CurrentRegion.Value
ReDim b(1 To UBound(a), 1 To UBound(a, 2))
For i = 1 To UBound(a)
If d.exists(a(i, 2)) Then
For j = 1 To UBound(a, 2)
b(d(a(i, 2)), j) = a(i, j)
Next
End If
Next
[i2].Resize(UBound(b), UBound(b, 2)) = b
End Sub