LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How to write a macro to select print ranges that vary monthly

Sub SetPrintArea()
Dim sh as Worksheet, rng as Range
for each sh in worksheets
set rng = sh.Range(sh.Cells(1,1),sh.Cells(rows.count,1).End( xlup))
sh.pageSetup.PrintArea = rng.Resize(,19).Address(external:=True)
Next
End Sub

Assuming that column A does not contain formulas but contains Data.

--
Regards,
Tom Ogilvy


"wilson@irco" wrote in message
...
Thank you Tom. Unfortunately not that simple. The data does always start

in
A1, but due to the condition that additional lines are added next mo.
formulas extend beyond this month's print range. There are also column
breaks (H,L and Q). The end column remains constant (S).

"Tom Ogilvy" wrote:

What determines the extent of the print range?

does the upper left corner never change and can we assume the print

ranges
are contiguous blocks of data separated from other data by the edge of

the
sheet or blank rows and columns. If so

Worksheets("Sheet2").Select
Range("B9").CurrentRegion.Select


--
Regards,
Tom Ogilvy

"wilson@irco" wrote in message
...
I have multiple spreadsheets with varying print ranges that change

monthly.
I'm trying to figure out the macro using sendkeys, but not working

very
well.
Any suggestions?






 
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
Macro to select Range to protect and unprotect ranges [email protected] Excel Worksheet Functions 2 May 15th 09 06:04 AM
How do I create a macro that will select a range that can vary in smokief Excel Discussion (Misc queries) 2 May 3rd 07 08:32 PM
Create a print macro that would automatically select print area? wastedwings Excel Worksheet Functions 7 August 22nd 05 10:36 PM
How to write a macro to print a dir on my c drive Tony Excel Programming 2 May 28th 05 11:54 PM
Macro (Print) - Calling Named Ranges KGlennC Excel Discussion (Misc queries) 1 March 19th 05 09:20 PM


All times are GMT +1. The time now is 03:56 PM.

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"