VBA: Paste new data after last row

knightwriter

New Member
Joined
Jul 4, 2016
Messages
17
Hi all,

I currently have a macro to pull data from separate excel files into one tab on a masterfile. Every time I run the macro it simply replaces the data in the masterfile.

Im looking to create VBA so that when I run the original macro its know to paste the new data at the end of the last row of data in my masterfile?

All help much appreciated.
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
The common logic is in defining the last cell (there're several methods). One of them is (pasting F1 cell into the last cell of column A):
Code:
Sub InsertIntoEnd()
    Dim last_row As Long
    last_row = Cells(Rows.Count, "A").End(xlUp).Row
    Range("F1").Copy Destination:=Cells(last_row + 1, "A")
End Sub
 
Upvote 0
Hi Sektor,

Many thanks for the reply.

So I have added the code to the bottom of the script and have included the sheet I want it to find the last row in but I get the following error. Any suggestions?



-- removed inline image ---


Sub InsertIntoEnd()
Dim last_row As Long
Sheets("Test").Select
last_row = Cells(Rows.Count, "A").End(xlUp).Row
Range("A").Copy Destination:=Cells(last_row + 1, "A")
End Sub
 
Upvote 0
Code:
Range("A[SIZE=3][COLOR=#ff0000][B]1[/B][/COLOR][/SIZE]").
 
Upvote 0
Great thanks,

So the vba is extracting data from a number of excel files and is still replacing the data within those same cells. And then macro that you kindly provided pulls the cell A into the last row.

I understand there is an ordering format that I must be missing but I want the macro to still extract the data and to put this new data into the last row, rather than what is happening above.

Thanks again.
 
Upvote 0

Forum statistics

Threads
1,215,575
Messages
6,125,628
Members
449,241
Latest member
NoniJ

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top