can I use a cell's contents as part of a custom header?

G

Guest

Excel 2003.
I'd like to use the contents of a cell as the custom header...too often I
forget to change the custom header to be the updated text. Specifically, I
need to list the _next_ month & current year in my page header. (ie, this is
February 06, so I'd like the header to read "March 06", without having to
open the custom head dialog box each time)
 
R

Ron Rosenfeld

On Sat, 11 Feb 2006 18:43:26 -0800, "NHVP Treasurer" <NHVP
Excel 2003.
I'd like to use the contents of a cell as the custom header...too often I
forget to change the custom header to be the updated text. Specifically, I
need to list the _next_ month & current year in my page header. (ie, this is
February 06, so I'd like the header to read "March 06", without having to
open the custom head dialog box each time)

Right click on the sheet tab and select View Code from the menu that opens.

Double Click on "This Workbook" in the active project (in the project explorer
window).

Paste the code below into the window that opens:

=========================
Private Sub Workbook_BeforePrint(Cancel As Boolean)

ActiveSheet.PageSetup.CenterHeader = _
Format(DateSerial(Year(Now), Month(Now) + 1, 1), "mmmm yy")

End Sub
================================
--ron
 

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