ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Print only down to last occupied row (https://www.excelbanter.com/excel-programming/401637-print-only-down-last-occupied-row.html)

mepetey

Print only down to last occupied row
 
Need a little help please guys, I have a worksheet that, after running
filters, presents me with the data I actually need. Trouble is the list
varies in length on each run. It's a pain to keep manually changing the
print area. Can anyone help with a routine to set the print area down to the
last "occupied" row?

Any help greatly appreciated.





Per Jessen[_2_]

Print only down to last occupied row
 
On 25 Nov., 11:46, "mepetey" wrote:
Need a little help please guys, I have a worksheet that, after running
filters, presents me with the data I actually need. Trouble is the list
varies in length on each run. It's a pain to keep manually changing the
print area. Can anyone help with a routine to set the print area down to the
last "occupied" row?

Any help greatly appreciated.


Put the code in the codesheet for ThisWorkbook.

Private Sub Workbook_BeforePrint(Cancel As Boolean)
FirstCell = "A1"
LastCell = Range("A1").End(xlDown).End(xlToRight).Address
ActiveSheet.PageSetup.PrintArea = Range(FirstCell, LastCell).Address
End Sub

Regards,

Per

excelent

Print only down to last occupied row
 
Range(Range("A1"), ActiveCell.SpecialCells(xlLastCell)).Select
ActiveSheet.PageSetup.PrintArea = Selection.Address


"mepetey" skrev:

Need a little help please guys, I have a worksheet that, after running
filters, presents me with the data I actually need. Trouble is the list
varies in length on each run. It's a pain to keep manually changing the
print area. Can anyone help with a routine to set the print area down to the
last "occupied" row?

Any help greatly appreciated.






mepetey

Print only down to last occupied row
 
Thanks for the fast response, how do I limit the print from column A to
column I?


"Per Jessen" wrote in message
...
On 25 Nov., 11:46, "mepetey" wrote:
Need a little help please guys, I have a worksheet that, after running
filters, presents me with the data I actually need. Trouble is the list
varies in length on each run. It's a pain to keep manually changing the
print area. Can anyone help with a routine to set the print area down to
the
last "occupied" row?

Any help greatly appreciated.


Put the code in the codesheet for ThisWorkbook.

Private Sub Workbook_BeforePrint(Cancel As Boolean)
FirstCell = "A1"
LastCell = Range("A1").End(xlDown).End(xlToRight).Address
ActiveSheet.PageSetup.PrintArea = Range(FirstCell, LastCell).Address
End Sub

Regards,

Per




mepetey

Print only down to last occupied row
 
Cracked it. Thanks !

"mepetey" wrote in message
...
Thanks for the fast response, how do I limit the print from column A to
column I?


"Per Jessen" wrote in message
...
On 25 Nov., 11:46, "mepetey" wrote:
Need a little help please guys, I have a worksheet that, after running
filters, presents me with the data I actually need. Trouble is the list
varies in length on each run. It's a pain to keep manually changing the
print area. Can anyone help with a routine to set the print area down to
the
last "occupied" row?

Any help greatly appreciated.


Put the code in the codesheet for ThisWorkbook.

Private Sub Workbook_BeforePrint(Cancel As Boolean)
FirstCell = "A1"
LastCell = Range("A1").End(xlDown).End(xlToRight).Address
ActiveSheet.PageSetup.PrintArea = Range(FirstCell, LastCell).Address
End Sub

Regards,

Per







All times are GMT +1. The time now is 07:55 PM.

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