View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.misc
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default Date command in Excel headers

Doug

See my reply about macros and where to place them and run them.

KC has posted event code which goes into Thisworkbook Module which is a
different module than a General module.

When you get into the VBE double-click on Thisworkbook to open the module.

Paste KC's code in there. It will run automatically when you print.

BTW.............yes, change rightfooter to leftheader.


Gord Dibben MS Excel MVP

On Fri, 12 Feb 2010 08:28:02 -0800, Doug
wrote:

Ok, so where do I put this macro?

"KC" wrote:

You have to use a workbook macro.

Private Sub Workbook_BeforePrint(Cancel As Boolean)
ActiveSheet.PageSetup.LeftHeader = Format(Date, "yyyy")
End Sub

--
Please remember to indicate when the post is answered so others can benefit
from it later.


"Doug" wrote:

Jim, I want to insert only the year, but I want it to update with each new
year. I use the same spreadsheet from year to year and I don't want to have
to manually put the year in the header for every month and every year. I
would like a command or formula that only inserts the year (2010) and not the
complete date (1/1/2010) like the "Date" button in Excel. This wa I don't
have to edit it each year.

Thanks!

"Jim Thomlinson" wrote:

So the value in the header is 2010 or is it 1/1/2010 formatted to show only
the year? If it is only the year then what date were you hoping for. What
formula did you want to use against the date?

--
HTH...

Jim Thomlinson


"Doug" wrote:

How do I enter a date command in a header that displays only the current year
and not the complete date?