Changing Page Headers with Variables

R

Ralph

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.
 
J

Jean-Paul Viel

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
 
R

Ralph

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top