Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Defining a print area in a macro

I am using Excel 2007.

I need to create a macro which identifies a range of cells as the print
area. The range varies and I need to macro to allow for this.

I need, within the macro, to go to the extreme bottom right hand end of the
data and create a print area which goes from that cell back to A1. The
problem is that the bottom right hand end of the data is not always in the
same place!

Any suggestions?

Many thanks in anticipation.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Defining a print area in a macro

Isn't this the way excel determines what to print if you don't specify a print
range?

I'd try removing the print range (er, setting it to "") to see if that worked
ok.

If not, maybe you could use row 1 and column A to determine where that bottom
right corner should be.

Dim LastRow as long
dim LastCol as long
dim myRng as range
with worksheets("Somesheetnamehere")
lastrow = .cells(.rows.count,"A").end(xlup).row
lastcol = .cells(1,.columns.count).end(xltoleft).column
set myrng = .range("A1",.cells(lastrow,lastcol))
.PageSetup.PrintArea = myrng.address(external:=true)
end with




Steven Nairn wrote:

I am using Excel 2007.

I need to create a macro which identifies a range of cells as the print
area. The range varies and I need to macro to allow for this.

I need, within the macro, to go to the extreme bottom right hand end of the
data and create a print area which goes from that cell back to A1. The
problem is that the bottom right hand end of the data is not always in the
same place!

Any suggestions?

Many thanks in anticipation.


--

Dave Peterson
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
Variable print area via a macro Andrew Excel Discussion (Misc queries) 9 September 16th 08 09:01 AM
Print Area Macro Question Vick Excel Discussion (Misc queries) 2 December 8th 07 01:02 AM
How do you set up a macro to reset the print area? Stuck2 Excel Discussion (Misc queries) 0 January 30th 06 03:50 PM
Pivot Table macro to set print area and print details of drill down data Steve Haskins Excel Discussion (Misc queries) 2 December 28th 05 04:59 PM
Create a print macro that would automatically select print area? wastedwings Excel Worksheet Functions 7 August 22nd 05 10:36 PM


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