View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default How to copy&paste a variable range rows and colums

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.

IK wrote:

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.


--

Dave Peterson