ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sub to append data below existing (https://www.excelbanter.com/excel-programming/416396-sub-append-data-below-existing.html)

Max

Sub to append data below existing
 
I've got source data in sheet: x,
in cols A to I, data from row2 down

In another sheet: y (received daily, for new data)
Data is in cols A to I (identical to x's structure), from row2 down
Col A in y can be used to determine the last data row

I'd like to run a sub to update x with the new data in y. The new data is to
simply append to x's cols A to I, below existing data, determined by last
data row in x's col A



Mike H

Sub to append data below existing
 
Hi,

Right click one of your sheet tabs, view code and paste this in and run it.

Sub mariner()
lastrow = Sheets("Y").Cells(Cells.Rows.Count, "A").End(xlUp).Row
Sheets("Y").Range("A2:I" & lastrow).Copy
lastrow = Sheets("X").Cells(Cells.Rows.Count, "A").End(xlUp).Row
Sheets("X").Range("A" & lastrow + 1).PasteSpecial
End Sub

Mike

"Max" wrote:

I've got source data in sheet: x,
in cols A to I, data from row2 down

In another sheet: y (received daily, for new data)
Data is in cols A to I (identical to x's structure), from row2 down
Col A in y can be used to determine the last data row

I'd like to run a sub to update x with the new data in y. The new data is to
simply append to x's cols A to I, below existing data, determined by last
data row in x's col A




Max

Sub to append data below existing
 
Many thanks, Mike. Works great.
(I installed into a std module)




All times are GMT +1. The time now is 07:34 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com