How to copy&paste a variable range rows and colums

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.
 
D

Dave Peterson

With no validity checks...

Option Explicit
Sub testme01()
Dim LastRowToPrint As Long

'what worksheet and cell holds that number
LastRowToPrint = Worksheets("sheet1").Range("x99").Value

'what's the worksheet to print?
Worksheets("sheet2").Range("A4:G" & LastRowToPrint).PrintOut preview:=True
End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

And I used preview:=true to save some trees while testing.
 

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