How to Copy and Paste a variable range

G

Guest

I have a formula returning a numerical # (like 25). I want to copy and paste
a range from Column A4 to Column GXX) Using that # number as the quantity of
rows that I have go to down.
Also the data is going to be selected from another sheet, using that
variable range specified in the sheet that the data is going to be pasted.
 
G

Guest

Let's say your formula is in cell A1, then:

Sub gsnu()
Dim howbig As Long
Dim r1 As Range
Dim r2 As Range

howbig = Range("A1").Value
Set r1 = Worksheets("Sheet2").Range(Cells(4, 1), Cells(howbig, "G"))
Set r2 = Worksheets("Sheet3").Range("A4")

r1.Copy r2
End Sub

will copy the defined block from Sheet2 to the same place in Sheet3
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top