How to Copy and Paste a variable range

  • Thread starter Thread starter Guest
  • Start date Start date
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.
 
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
 
Back
Top