LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Vb to set print area for dynamic pages

I have a workbook with four pages, each with the same number of columns, but
various numbers of rows. I have a macro to automatically set the print area
for those pages and it works just fine. Now I have to add a column to just
one of the pages in the workbook. The macro I have naturally excludes the
new last column. I suspect more changes are on the horizon i.e some pages
growing, others shrinking. I'd rather have Excel 'see' what columns are
present, rather than continually altering the code when I make changes. I
tried to use XLRight instead of naming the column "U", but that doesn't work.
I think I'm on the right track but probably not using the correct syntax.
Here is the code. Any one have any ideas?

Dim sh As Worksheet
For Each sh In ActiveWorkbook.Worksheets
sh.Activate
Dim LastRow As Long

With ActiveSheet
LastRow = .Cells(.Rows.Count, "D").End(xlUp).Row
.PageSetup.PrintArea = "A1:U" & LastRow
End With
Next
 
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
Remove print area from multiples pages Linda Excel Discussion (Misc queries) 1 April 8th 10 06:21 PM
Print Area ranges print on separate pages? Lyndon Excel Discussion (Misc queries) 1 December 29th 06 05:22 PM
Set print area on several pages at once in Excell Workbook? willow Excel Discussion (Misc queries) 2 August 23rd 05 01:31 AM
Print area will only go up to 101 pages Martc Excel Discussion (Misc queries) 1 June 23rd 05 12:50 AM
print pages when text area changes in size dizzy Excel Programming 0 January 25th 04 01:28 AM


All times are GMT +1. The time now is 05:09 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"