I am new to VBA and am stuck somewhere. I need to copy the last row of column A to column H and paste it to the last row of column I. The last rows of the column will always change.
eg; my data is in A2: H2 and I5 - the last cell with the data.
My code should be copied A2: H2 and paste it A3: H5. And the second time I run the macro (after adding new data to the corresponding columns) it should be copied A6: H6 and paste it to the last row of column I.
I wrote two codes that did not fit my needs.
first code;
Sub OrderList1() Range("a65536").End(xlUp).Resize(1, 8).Copy _ (Cells(Cells(Rows.Count, 9).End(xlUp).Row, 1)) End Sub
this code skips A3: H4 and only inserts into A5: H5
second code:
Sub OrderList2() Range("A2:H2").Copy Range(Cells(2, 8), _ Cells(Cells(Rows.Count, 9).End(xlUp).Row, 1)) End Sub
it copies A2: H3 and pastes it A5: H5, but when I add new data, it doesn't start pasting from A5: H5. It starts with A2: H2 and overwrites the old data. I see what I need to change, the range should be a dynamic range, as in the first code, but I can not write the code.
I am very grateful for the help.
source share