Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Dynamic print area

I am having trouble creating a dynamic print area. I need to print a sheet
that is updated from other sheets in the same workbook. There will always be
data in columns A-G and a variable number of rows.

LngLastRow = ActiveSheet.Range("G65536").End(xlUp).Row
ActiveSheet.Range("A1:G" & LngLastRow).Select
ActiveSheet.PageSetup.PrintArea = ("A1:G" & LngLastRow)

I use the above code to establish the range of cells used and to then
establish the print area. It appears to work because dashed lines are around
the selected range, but it does not print as I had hoped. I was expecting, in
this case, to have 2 printed sheets , but I have 4 printed sheets with
columns F & G on pages 3 and 4.

TIA
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Dynamic print area

Hi Harley

You can change the margins in pagesetup and maybe

.PageSetup.FitToPagesWide = 1



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Harley" wrote in message ...
I am having trouble creating a dynamic print area. I need to print a sheet
that is updated from other sheets in the same workbook. There will always be
data in columns A-G and a variable number of rows.

LngLastRow = ActiveSheet.Range("G65536").End(xlUp).Row
ActiveSheet.Range("A1:G" & LngLastRow).Select
ActiveSheet.PageSetup.PrintArea = ("A1:G" & LngLastRow)

I use the above code to establish the range of cells used and to then
establish the print area. It appears to work because dashed lines are around
the selected range, but it does not print as I had hoped. I was expecting, in
this case, to have 2 printed sheets , but I have 4 printed sheets with
columns F & G on pages 3 and 4.

TIA



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Dynamic print area


Harley,
Try something like this. I'm not one of the experts, but this worked
for me. Adapt as necessary.

Option Explicit
Private Sub PrintArea()
Dim LngLastRow As Long

LngLastRow = ActiveSheet.Range("G65536").End(xlUp).Row
ActiveSheet.Range("A1:G" & LngLastRow).Select

With ActiveSheet.PageSetup
..PrintArea = ("A1:G" & LngLastRow)
..FitToPagesWide = 1
..FitToPagesTall = False

End With
End Sub

HTH


--
Casey


------------------------------------------------------------------------
Casey's Profile: http://www.excelforum.com/member.php...fo&userid=4545
View this thread: http://www.excelforum.com/showthread...hreadid=483666

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Dynamic print area

Thank you Ron and Casey. The code now works as I had hoped.
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
Print Area as dynamic range? Michael.Tarnowski Excel Worksheet Functions 1 March 8th 09 04:02 PM
Dynamic Print Area Huddle Excel Discussion (Misc queries) 7 February 7th 07 04:55 PM
dynamic print area based on cell value [email protected] Excel Worksheet Functions 2 June 14th 06 04:23 AM
dynamic print area GeorgeW Excel Worksheet Functions 7 February 23rd 06 06:11 PM
How do you turn off a print area for a page? (no print area) Grunen Excel Discussion (Misc queries) 4 October 8th 05 07:46 PM


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

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

About Us

"It's about Microsoft Excel"