Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Variable print area via a macro | Excel Discussion (Misc queries) | |||
Print Area Macro Question | Excel Discussion (Misc queries) | |||
How do you set up a macro to reset the print area? | Excel Discussion (Misc queries) | |||
Pivot Table macro to set print area and print details of drill down data | Excel Discussion (Misc queries) | |||
Create a print macro that would automatically select print area? | Excel Worksheet Functions |