Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Command line to filter on the last date | Excel Discussion (Misc queries) | |||
Macro command control by date | Excel Worksheet Functions | |||
&[saved date] for headers in outlook applications | Excel Discussion (Misc queries) | |||
How do I set up a sheet with date headers one week apart. | New Users to Excel | |||
Date Command to Get the Sunday Before the First of the Month | Excel Worksheet Functions |