![]() |
VBA to set print area of single page
I have limited knowlege in VBA and would like help modifying the cod below. I have placed this in the workbook area of the VB editor....however I need this to really only apply to one page of th workbook. As is it is interferring with the other pages. Basically o the sheet "Hourly Update" I need it to print rows 1-(variable) based o column c (only print as far down as there are entries in column c). But for the other pages I would like it to print with the individua print areas already assigned to that page. Here is the code that I currently have: Private Sub Workbook_BeforePrint(Cancel As Boolean) ActiveSheet.PageSetup.PrintArea = Range("A1:Ak" & _ Range("c" & Rows.Count).End(xlUp).Row).Resize.Address End Sub I'm sure it is a lot easier than I am trying to make it, but I've trie everything that I know how. Thanks in advance, Jenn -- shikamikamoomo ----------------------------------------------------------------------- shikamikamoomoo's Profile: http://www.excelforum.com/member.php...fo&userid=2101 View this thread: http://www.excelforum.com/showthread.php?threadid=51600 |
VBA to set print area of single page
Private Sub Workbook_BeforePrint(Cancel As Boolean)
if Activesheet.Name = "Hourly Update" then ActiveSheet.PageSetup.PrintArea = Range("A1:Ak" & _ Range("c" & Rows.Count).End(xlUp).Row).Resize.Address End If End Sub -- Regards, Tom Ogilvy "shikamikamoomoo" <shikamikamoomoo.23pega_1140734102.676@excelforu m-nospam.com wrote in message news:shikamikamoomoo.23pega_1140734102.676@excelfo rum-nospam.com... I have limited knowlege in VBA and would like help modifying the code below. I have placed this in the workbook area of the VBA editor....however I need this to really only apply to one page of the workbook. As is it is interferring with the other pages. Basically on the sheet "Hourly Update" I need it to print rows 1-(variable) based on column c (only print as far down as there are entries in column c). But for the other pages I would like it to print with the individual print areas already assigned to that page. Here is the code that I currently have: Private Sub Workbook_BeforePrint(Cancel As Boolean) ActiveSheet.PageSetup.PrintArea = Range("A1:Ak" & _ Range("c" & Rows.Count).End(xlUp).Row).Resize.Address End Sub I'm sure it is a lot easier than I am trying to make it, but I've tried everything that I know how. Thanks in advance, Jenny -- shikamikamoomoo ------------------------------------------------------------------------ shikamikamoomoo's Profile: http://www.excelforum.com/member.php...o&userid=21018 View this thread: http://www.excelforum.com/showthread...hreadid=516008 |
VBA to set print area of single page
I knew it was that simple!! So close, yet so far. :D Thanks for the help. -- shikamikamoomoo ------------------------------------------------------------------------ shikamikamoomoo's Profile: http://www.excelforum.com/member.php...o&userid=21018 View this thread: http://www.excelforum.com/showthread...hreadid=516008 |
All times are GMT +1. The time now is 11:36 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com