ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   How can I add present month, as number, to an header in excel? (https://www.excelbanter.com/excel-discussion-misc-queries/123448-how-can-i-add-present-month-number-header-excel.html)

Agnes _TASOT

How can I add present month, as number, to an header in excel?
 
Have a work book with many sheets and want to have as part of a header:

"Sheet Name" - "Present Month" - "Present Year" that will update automatically

header would look like "name-12-06" was hoping I could do
&[Tab] - &[Month] - &[Year] the &[Tab] is ok, any thoughts on the rest.

Agnes

Gord Dibben

How can I add present month, as number, to an header in excel?
 
Agnes

Could you live with a macro?

Sub Sheet_Date_Header()
ActiveSheet.PageSetup.RightHeader = ActiveSheet.Name & _
"-" & Format(Now, "mm") & _
"-" & Format(Now, "yy")
End Sub

If you want completely automatic you could use in a BeforePrint macro.

Private Sub Workbook_BeforePrint(Cancel As Boolean)
ActiveSheet.PageSetup.RightHeader = ActiveSheet.Name & _
"-" & Format(Now, "mm") & _
"-" & Format(Now, "yy")
End Sub


Gord Dibben MS Excel MVP


On Thu, 21 Dec 2006 10:01:02 -0800, Agnes _TASOT <Agnes
wrote:

Have a work book with many sheets and want to have as part of a header:

"Sheet Name" - "Present Month" - "Present Year" that will update automatically

header would look like "name-12-06" was hoping I could do
&[Tab] - &[Month] - &[Year] the &[Tab] is ok, any thoughts on the rest.

Agnes




All times are GMT +1. The time now is 03:21 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com