Paste to last row without defining Lastrow

RockandGrohl

Well-known Member
Joined
Aug 1, 2018
Messages
790
Office Version
  1. 365
Platform
  1. Windows
Hi, colleague asked me this and I've seen it before but can't successfully google what I want.


Basically in a single copy operation from one sheet to another you can say, for instance:

VBA Code:
Range("A2").copy Destination:=temp.range("A" & Lastrow + 1)

That's the normal way, or one of them.

What I want to know is how to paste to the bottom of the data set, without setting a new last row. If that above code was in a loop I'd have to switch to the temp tab and re-define the last row each time.

While computationally it takes no time at all, is it not better practice to cut down unnecessary code and instead paste like this:

VBA Code:
Range("A2").copy Destination:=temp.cells(rows.count, "A").end(xlup).row + 1

When I try this, nothing is pasted. Any help? Thanks.
 
It should really be temp.rows.count and not just rows.count to be safe, but otherwise there is nothing there that requires switching sheets.
 
Upvote 0

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

Forum statistics

Threads
1,215,026
Messages
6,122,743
Members
449,094
Latest member
dsharae57

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