Hi,
I want to make a macro to copy the first rows to the last rows that is empty in column A (below: A4 to E6) from workbook called "XXX" to my current workbook called "ZZZ".
<tbody>
</tbody>
I want to make a macro to copy the first rows to the last rows that is empty in column A (below: A4 to E6) from workbook called "XXX" to my current workbook called "ZZZ".
A | B | C | D | E | |
1 | 2252 | 1 | 7 | 13 | AAA |
2 | 2253 | 2 | 8 | 14 | BBB |
3 | 2254 | 3 | 9 | 15 | CCC |
4 | 4 | 10 | 16 | DDD | |
5 | 5 | 11 | 17 | EEE | |
6 | 6 | 12 | 18 | FFF |
<tbody>
</tbody>
Code:
Sub CopyRow()
Dim LastRow As Long, FirstRow As Long
LastRow=Cells(Rows.Count,"B").End(xlUp).Row
FirstRow=Columns("A").Find("",,xlValues, , xlRows, xlPrevious, , , False).Row + 1
Workbooks.Open Filename:="...XXX.xlsx"
Sheets("XXX sheet").Select
Range("A" & FirstRow & ":E" & LastRow).Copy
Window("ZZZ.xlsm").Activate
Range("A2").Select
ActiveSheet.Paste
Workbooks("XXX.xlsx").Close savechanges:=FALSE
End Sub