#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default Print Range

I have finance spreadsheets i.e. P&Ls for different countries. Each of the
spreadsheets has a different last column which has data in it. These reports
are generated from our finance reporting tool. Instead of manually setting a
print range, is there a way of using VBA to set the range which takes into
account the last column with data. The last row in all cases should be
710.[egs of print areas : .PrintArea = "$A$1:$BM$710" ; .PrintArea =
"$A$1:$BA$710"]
I dont know what the print range will be until the report has been ran. I
wish to attach the macro to the blank template which is used by the
reporting tool. When a country specific report is ran the relevant columns
will be populated.

Thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 523
Default Print Range

This will work:

Sub demo()

Dim ws As Worksheet
Set ws = ActiveSheet

ws.PageSetup.PrintArea = ws.Range("a1").Resize(710,
ws.Cells.SpecialCells(xlCellTypeLastCell).Column). Address

End Sub




"manfareed" wrote:

I have finance spreadsheets i.e. P&Ls for different countries. Each of the
spreadsheets has a different last column which has data in it. These reports
are generated from our finance reporting tool. Instead of manually setting a
print range, is there a way of using VBA to set the range which takes into
account the last column with data. The last row in all cases should be
710.[egs of print areas : .PrintArea = "$A$1:$BM$710" ; .PrintArea =
"$A$1:$BA$710"]
I dont know what the print range will be until the report has been ran. I
wish to attach the macro to the blank template which is used by the
reporting tool. When a country specific report is ran the relevant columns
will be populated.

Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default Print Range

Many Thanks ... It works

"Sam Wilson" wrote:

This will work:

Sub demo()

Dim ws As Worksheet
Set ws = ActiveSheet

ws.PageSetup.PrintArea = ws.Range("a1").Resize(710,
ws.Cells.SpecialCells(xlCellTypeLastCell).Column). Address

End Sub




"manfareed" wrote:

I have finance spreadsheets i.e. P&Ls for different countries. Each of the
spreadsheets has a different last column which has data in it. These reports
are generated from our finance reporting tool. Instead of manually setting a
print range, is there a way of using VBA to set the range which takes into
account the last column with data. The last row in all cases should be
710.[egs of print areas : .PrintArea = "$A$1:$BM$710" ; .PrintArea =
"$A$1:$BA$710"]
I dont know what the print range will be until the report has been ran. I
wish to attach the macro to the blank template which is used by the
reporting tool. When a country specific report is ran the relevant columns
will be populated.

Thanks

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 range won't print Cheri K Excel Discussion (Misc queries) 2 February 25th 10 11:49 PM
Print Range MikieSlats Setting up and Configuration of Excel 0 September 28th 07 08:46 AM
Print Blank Pgs - Preview margins outside print range dsm Excel Discussion (Misc queries) 0 October 25th 06 06:17 PM
Can you get the range reference for each page in a worksheet print range? Crosby Excel Programming 3 April 12th 05 06:06 PM
Excel 2000 VBA - Set Print Range in dynamic range sub_pop[_5_] Excel Programming 2 July 27th 04 08:01 PM


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