Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 460
Default Date command in Excel headers

How do I enter a date command in a header that displays only the current year
and not the complete date?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default Date command in Excel headers

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?

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 460
Default Date command in Excel headers

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?

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 57
Default Date command in Excel headers

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?

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Date command in Excel headers

You mean a header as in Footers and Headers for print setup?

Sub YearInFooter()
ActiveSheet.PageSetup.RightFooter = Year(Now)
End Sub

For all sheets in workbook.

Sub Date_All_Sheets()
Set wkbktodo = ActiveWorkbook
For Each WS In wkbktodo.Worksheets
WS.PageSetup.RightFooter = Year(Now)
Next
End Sub


Gord Dibben MS Excel MVP


On Thu, 28 Jan 2010 13:31:01 -0800, Doug
wrote:

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




  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 460
Default Date command in Excel headers

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?

  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 460
Default Date command in Excel headers

Yes, I mean a header as in Footers and Headers for print setup. Ok, so where
do I put this macro to make it work. Also, if I want the date to appear as a
left header instead of a right footer do I simply change "RightFooter" to
"LeftHeader"?

Thanks!

"Gord Dibben" wrote:

You mean a header as in Footers and Headers for print setup?

Sub YearInFooter()
ActiveSheet.PageSetup.RightFooter = Year(Now)
End Sub

For all sheets in workbook.

Sub Date_All_Sheets()
Set wkbktodo = ActiveWorkbook
For Each WS In wkbktodo.Worksheets
WS.PageSetup.RightFooter = Year(Now)
Next
End Sub


Gord Dibben MS Excel MVP


On Thu, 28 Jan 2010 13:31:01 -0800, Doug
wrote:

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


.

  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 460
Default Date command in Excel headers

Nevermind, I found it.

"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?

  #9   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 460
Default Date command in Excel headers

Nevermind, I found it and answered my own question.

Thanks!

"Doug" wrote:

Yes, I mean a header as in Footers and Headers for print setup. Ok, so where
do I put this macro to make it work. Also, if I want the date to appear as a
left header instead of a right footer do I simply change "RightFooter" to
"LeftHeader"?

Thanks!

"Gord Dibben" wrote:

You mean a header as in Footers and Headers for print setup?

Sub YearInFooter()
ActiveSheet.PageSetup.RightFooter = Year(Now)
End Sub

For all sheets in workbook.

Sub Date_All_Sheets()
Set wkbktodo = ActiveWorkbook
For Each WS In wkbktodo.Worksheets
WS.PageSetup.RightFooter = Year(Now)
Next
End Sub


Gord Dibben MS Excel MVP


On Thu, 28 Jan 2010 13:31:01 -0800, Doug
wrote:

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


.

  #10   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Date command in Excel headers

Doug

If you're not familiar with VBA and macros, see David McRitchie's site for
more on "getting started".

http://www.mvps.org/dmcritchie/excel/getstarted.htm

or Ron de De Bruin's site on where to store macros.

http://www.rondebruin.nl/code.htm

In the meantime..........

First...create a backup copy of your original workbook.

To create a General Module, hit ALT + F11 to open the Visual Basic Editor.

Hit CRTL + r to open Project Explorer.

Find your workbook/project and select it.

Right-click and InsertModule. Paste the code in there. Save the
workbook and hit ALT + Q to return to your workbook.

Run or edit the macro by going to ToolMacroMacros.

You can also assign this macro to a button or a shortcut key combo.


Gord Dibben MS Excel MVP


On Fri, 12 Feb 2010 08:30:01 -0800, Doug
wrote:

Yes, I mean a header as in Footers and Headers for print setup. Ok, so where
do I put this macro to make it work. Also, if I want the date to appear as a
left header instead of a right footer do I simply change "RightFooter" to
"LeftHeader"?

Thanks!

"Gord Dibben" wrote:

You mean a header as in Footers and Headers for print setup?

Sub YearInFooter()
ActiveSheet.PageSetup.RightFooter = Year(Now)
End Sub

For all sheets in workbook.

Sub Date_All_Sheets()
Set wkbktodo = ActiveWorkbook
For Each WS In wkbktodo.Worksheets
WS.PageSetup.RightFooter = Year(Now)
Next
End Sub


Gord Dibben MS Excel MVP


On Thu, 28 Jan 2010 13:31:01 -0800, Doug
wrote:

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


.




  #11   Report Post  
Posted to microsoft.public.excel.misc
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?


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Command line to filter on the last date mulehead Excel Discussion (Misc queries) 2 May 13th 08 08:27 PM
Macro command control by date Param Excel Worksheet Functions 2 May 12th 06 04:26 PM
&[saved date] for headers in outlook applications LMMBLS? Excel Discussion (Misc queries) 0 April 3rd 06 04:09 PM
How do I set up a sheet with date headers one week apart. mossbury New Users to Excel 10 January 20th 06 03:26 PM
Date Command to Get the Sunday Before the First of the Month Minitman Excel Worksheet Functions 6 December 2nd 05 09:34 PM


All times are GMT +1. The time now is 09:02 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"