ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Set Print Area with a macro (https://www.excelbanter.com/excel-programming/304425-set-print-area-macro.html)

June

Set Print Area with a macro
 
I am automating Excel thru Access. I have am exporting a
query to Excel and then formating it to print. Sometimes
I may have 200 records and sometimes I may have 50. I
want to set the print area in the macro. How do I do
this? Does anyone have any code I could use for a jumping
off place?

Ron de Bruin

Set Print Area with a macro
 
Hi June

If you clear your print area Excel will print all
te records on your sheet



--
Regards Ron de Bruin
http://www.rondebruin.nl


"June" wrote in message ...
I am automating Excel thru Access. I have am exporting a
query to Excel and then formating it to print. Sometimes
I may have 200 records and sometimes I may have 50. I
want to set the print area in the macro. How do I do
this? Does anyone have any code I could use for a jumping
off place?




Kelly n espaņol[_6_]

Set Print Area with a macro
 
I have a feeling that Ron's answer is exactly what you are looking for.

But if you have a sheet with a lot of data and you wish to set
specific print area such that you WILL NOT print all the data (only th
first half, for example)...

then you could use something like:

ActiveSheet.PageSetup.PrintArea = "$A$1:$G$19"

**OR**

Workbooks("Name.xls").Sheets("SheetName").PageSetu p.PrintArea
"$A$1:$G$19

--
Message posted from http://www.ExcelForum.com


June

Set Print Area with a macro
 
I guess I didn't state my question correctly. I want
Excel to detect the range of cells and set the print area.

Does that make sense?

Thanks,
June


-----Original Message-----
I have a feeling that Ron's answer is exactly what you

are looking for.

But if you have a sheet with a lot of data and you wish

to set a
specific print area such that you WILL NOT print all the

data (only the
first half, for example)...

then you could use something like:

ActiveSheet.PageSetup.PrintArea = "$A$1:$G$19"

**OR**

Workbooks("Name.xls").Sheets

("SheetName").PageSetup.PrintArea =
"$A$1:$G$19"


---
Message posted from http://www.ExcelForum.com/

.


Ron de Bruin

Set Print Area with a macro
 
Hi June

If you really want to set the print area

Sub test()
With ActiveSheet
..PageSetup.PrintArea = .UsedRange.Address
End With
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"June" wrote in message ...
I guess I didn't state my question correctly. I want
Excel to detect the range of cells and set the print area.

Does that make sense?

Thanks,
June


-----Original Message-----
I have a feeling that Ron's answer is exactly what you

are looking for.

But if you have a sheet with a lot of data and you wish

to set a
specific print area such that you WILL NOT print all the

data (only the
first half, for example)...

then you could use something like:

ActiveSheet.PageSetup.PrintArea = "$A$1:$G$19"

**OR**

Workbooks("Name.xls").Sheets

("SheetName").PageSetup.PrintArea =
"$A$1:$G$19"


---
Message posted from http://www.ExcelForum.com/

.





All times are GMT +1. The time now is 12:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com