Macro to copy and paste a variable range between worksheets

mdesroc

New Member
Joined
Dec 8, 2012
Messages
18
What is the most efficient way to take all of the values from A2 down in worksheet 1 and past it into worksheet 2 starting with A7? The issue I am running into the is number of values I will be copying changes and could go from as small as one row all the way up to 1000s of rows.

Im still learning VBA, so any advice or ideas would be appreciated
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
If A2 is the first row of data you could use something like Range("A2").currentRegion.Copy then move to worksheet and paste from there, have you tried recording the macro to do this to see the code?
 
Upvote 0
"take all of the values from A2 down in worksheet 1"

If you mean all values from a single column where you do not know the last row used, you can use something like:
Code:
Dim Last_Row as Long
With Sheets("Sheet1")
  Last_Row = .Range("A" & Rows.Count).End(xlUp).Row
  .Range("A2:A" & Last_Row).Copy
End With
Sheets("Sheet2").Range("A7").PasteSpecial xlPastevalues
 
Upvote 0

Forum statistics

Threads
1,214,929
Messages
6,122,314
Members
449,081
Latest member
tanurai

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