ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Changing Page Headers with Variables (https://www.excelbanter.com/excel-programming/277183-changing-page-headers-variables.html)

Ralph[_4_]

Changing Page Headers with Variables
 
Can anyone help me.

I have a an excel file with formulas saved as a
template. When I open the file I need to automatically
add the StartDate and StopDate to the Page Header.

The End-User enters 2 dates that are saved as variables.
The start date (StartDate), and the end date (StopDate).
these dates are entered in the following format xx/yy/zzzz.

I want to add this to the Top Right side of the Printed
page. Since the dates change everytime I figured I could
use the variables. However I do Not know how to
accomplish this.

What I want to appear on the Top Right of the page is:

Traffic Data from 09/01/2003 to 09-10/2003

Any and all help will be greatly appreciated.

Jean-Paul Viel

Changing Page Headers with Variables
 
Hi,

Add this code to the module ThisWorkbook:



Private Sub Workbook_BeforePrint(Cancel As Boolean)

ActiveSheet.PageSetup.RightHeader = "Traffic Data from " &
CStr(StartDate) & " to " & CStr(StopDate)

End Sub




--
JP

http://www.solutionsvba.com


"Ralph" wrote in message
...
Can anyone help me.

I have a an excel file with formulas saved as a
template. When I open the file I need to automatically
add the StartDate and StopDate to the Page Header.

The End-User enters 2 dates that are saved as variables.
The start date (StartDate), and the end date (StopDate).
these dates are entered in the following format xx/yy/zzzz.

I want to add this to the Top Right side of the Printed
page. Since the dates change everytime I figured I could
use the variables. However I do Not know how to
accomplish this.

What I want to appear on the Top Right of the page is:

Traffic Data from 09/01/2003 to 09-10/2003

Any and all help will be greatly appreciated.




Ralph[_4_]

Changing Page Headers with Variables
 
JP,

THanks that added the Text I wanted however it over-
wrote the Font command.

The Font was originally set for 12 Bold, now it comes
up the default 10 Regular.

Any Ideas.

Thanks again for your assistance.

-----Original Message-----
Hi,

Add this code to the module ThisWorkbook:



Private Sub Workbook_BeforePrint(Cancel As Boolean)

ActiveSheet.PageSetup.RightHeader = "Traffic Data

from " &
CStr(StartDate) & " to " & CStr(StopDate)

End Sub




--
JP

http://www.solutionsvba.com


"Ralph" wrote in message
...
Can anyone help me.

I have a an excel file with formulas saved as a
template. When I open the file I need to automatically
add the StartDate and StopDate to the Page Header.

The End-User enters 2 dates that are saved as variables.
The start date (StartDate), and the end date (StopDate).
these dates are entered in the following format

xx/yy/zzzz.

I want to add this to the Top Right side of the Printed
page. Since the dates change everytime I figured I

could
use the variables. However I do Not know how to
accomplish this.

What I want to appear on the Top Right of the page is:

Traffic Data from 09/01/2003 to 09-10/2003

Any and all help will be greatly appreciated.



.



All times are GMT +1. The time now is 12:05 AM.

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