View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Ron Rosenfeld
 
Posts: n/a
Default can I use a cell's contents as part of a custom header?

On Sat, 11 Feb 2006 18:43:26 -0800, "NHVP Treasurer" <NHVP
wrote:

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