
Sub OpenFileCopyRows()
Set sh = ThisWorkbook.Sheets(1)
LR1 = sh.Cells(Rows.Count, "J").End(xlUp).Row
Filename = ThisWorkbook.Path & "fileA.xlsx"
Workbooks.Open (Filename)
LR2 = Cells(Rows.Count, "J").End(xlUp).Row
For r = 4 To LR1
cod = sh.Range("J" & r)
For rr = 4 To LR2
If Range("J" & rr) = cod Then
sh.Range("B" & r & ":I" & r).Value = Range("B" & rr & ":I" & rr).Value
End If
Next
Next
ActiveWorkbook.Close
End Sub |
