Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 709
Default pagesetup.printarea Print non contiguous areas # rows varies

Using variables to hold print ranges. How do I assign variables to
..pageSetup.PrintArea = ???
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default pagesetup.printarea Print non contiguous areas # rows varies

dim TopRow as long
dim BotRow as long
dim LeftCol as variant 'string or number!
dim rightcol as variant 'string or number

toprow = 1
botrow = 32
leftcol = "C"
rightcol = 92

with activesheet
.pagesetup.printarea _
= .range(.cells(toprow,leftcol), .cells(botrow,rightcol)) _
.address(external:=true)
end with

If this doesn't help, what are your variables and what do they hold?

Richard wrote:

Using variables to hold print ranges. How do I assign variables to
.pageSetup.PrintArea = ???


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default pagesetup.printarea Print non contiguous areas # rows varies

Hello Richard,

You can name the range and then use the named range as the print area.
Range("A1:I16,A25:I35,A64:I81").Name = "MyPrintRange"

ActiveSheet.PageSetup.PrintArea = "MyPrintRange"

However, the above will insert a page feed between the non contiguous rows.
In Page setup it also converts the named range to actual cell addresses.

You can copy the non contiguous rows to a separate temporary worksheet and
there will be no non contiguous rows and then the address of the UsedRange
can be used for the PrintArea.

Sub PrtNonContiguous()

With Sheets("Sheet1")
.Range("A1:I16,A25:I35,A64:I81").Copy _
Sheets("Sheet2").Range("A1")
End With

With Sheets("Sheet2")
.PageSetup.PrintArea = .UsedRange.Address
End With

End Sub

--
Regards,

OssieMac


"Richard" wrote:

Using variables to hold print ranges. How do I assign variables to
.pageSetup.PrintArea = ???

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
set PageSetup.PrintArea from MS Project SoftwareTester Excel Programming 1 October 13th 09 04:24 PM
Can i print non-contiguous areas on one page?? yiota Excel Discussion (Misc queries) 2 March 27th 06 02:51 PM
Can i print non-contiguous areas on one page yiota Excel Worksheet Functions 1 March 27th 06 12:30 PM
ActiveSheet.PageSetup.PrintArea variable ? MAS Excel Programming 2 May 2nd 05 05:45 PM
Help - Error: Unable to set the PrintArea property of the PageSetup class Marie J-son[_5_] Excel Programming 3 January 5th 05 02:04 PM


All times are GMT +1. The time now is 07:46 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"