Sub dj()
Application.ScreenUpdating = False
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Dim r As Long
Dim rs As Long
Dim ar As Variant, br As Variant
Dim i As Long
Dim s As Long
Set ws1 = Sheet1
Set ws2 = Sheet2
r = ws1.Cells(ws1.Rows.Count, 4).End(xlUp).Row
rs = ws2.Cells(ws2.Rows.Count, 1).End(xlUp).Row
ar = ws2.Range("a1:aw" & rs)
br = ws1.Range("a5:n" & r)
For i = 2 To UBound(br)
For s = 2 To UBound(ar)
If br(i, 4) = ar(s, 1) Then
br(i, 1) = i - 1
br(i, 2) = ar(s, 2)
br(i, 3) = ar(s, 4)
br(i, 6) = ar(s, 5)
br(i, 7) = ar(s, 8)
br(i, 8) = ar(s, 9)
br(i, 9) = ar(s, 12)
br(i, 10) = ar(s, 13)
br(i, 11) = ar(s, 21)
br(i, 12) = ar(s, 23)
br(i, 13) = ar(s, 26)
br(i, 14) = ar(s, 45)
Exit For
End If
Next s
Next i
ws1.Range("a5:n" & r) = br
Application.ScreenUpdating = True
End Sub
|