Normally, the dates used by Excel in headers and footers (with the [DATE] code) are based on the regional settings controlled by Windows. Thus, if your local settings show the date in a specific format in Windows itself, that is the same format that Excel will use in headers and footers.
This can be a drawback if you are required to maintain a certain type of system date format for compatibility with other systems in your office, but you need to use a different date format in the header or footer of a specific worksheet. The only way around this problem is to either change the regional settings within Windows, or revert to using a macro to set the appropriate area of your header or footer.
For instance, let's say you wanted to set the right header equal to the current date in the format m/d/yy. To do that, you can use a very simple macro, such as the following:
Sub HeaderDate() ActiveSheet.PageSetup.RightHeader = Format(Date, "m/d/yy") End Sub
To use this, simply run it and it adds the date, in the specified format, into the right section of the header. If you want the information added to a different place in the footer or header, you simply replace the RightHeader portion of the macro with one of the following: LeftFooter, CenterFooter, RightFooter, LeftHeader, or CenterHeader.
To change the format in which the date is added, simply change the format used in the Format function. There are all sorts of patterns you can use for the date; check the online Help system for information about the Format function in VBA.
You should note that dates added to headers or footers in this manner are not dynamic, as is the result of the [DATE] code. When you use the macro to insert the date, it is inserted as a text string. If you later want to change the date to something else (like the then-current date), you will need to rerun the macro.
Note:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2188) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Specifying Date Formats in Headers.
Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!
If your workbook is destined for the printed page, you need to be concerned with the layout of that page. Excel allows ...
Discover MorePlace an ampersand into the text of a page header or footer, and you might be surprised to see it missing in your ...
Discover MoreDo you want to change the headers and footers that appear on different pages of your printout? Here's how you can get ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2020-05-28 11:19:09
Paula McSorley
This does work, but for some very odd reason it resets my Dynamic Print range to a static one - so the dynamic print range application only can be used once before I need to go into the Name Manager and reset the now static print_area to the referenced dynamic print range I previously had it configured for. All I need to do is run this tiny VBA macro you have outlined above, and it resets the applicable Name Manager value. I don't understand the connection, do you? Is there a way around that?
2019-05-21 16:19:50
jay
Just want to change the date format to 01-JAN-19. Changed regional settings for short date and added &[Date] to right header. No change in header format still appears as 01-01-19. I don't want to have to code to do this. That is why I pay for excel
2017-01-25 11:53:59
Ronda Ridley
I have a folder that contain the following file names: Jan 1, Jan 2, Jan 3, Jan 4, etc.
I need to run a macro to change the year of each file from 2017 to 2018. My macro reads:
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = "&""Arial Narrow,Bold""&16Sign-Out"
.RightHeader = "&""Arial Narrow,Bold""&17January 11, 2018"
It prints "Sign-O " and "January 11, 20"
instead of "Sign-Out and January 11, 2018.
Please help.
2016-07-26 10:39:32
Piecevcake
Hi,
I use the key shortcut shift+ctrl+; to insert the current date in a text cell.
I have read elsewhere that the inserted date format is determined by windows regional settings, but my windows region date setting is d/m/yy. The inserted date is d/m/yyyy.
I have to keep the cell as text, so I cannot use the date formatting ... (Because I also use Dragon Naturally speaking to dictate dates, and excel date formatting does not work with it)
Can you help with how to tell excel what to actually insert, rather than trying to format it afterwards?
2016-07-26 10:37:02
piecevcake
Hi,
I use the key shortcut to insert the current date in a text cell.
I have read elsewhere that the inserted date format is determined by windows regional settings, but my windows region date setting is d/m/yy. The inserted date is d/m/yyyy.
I have to keep the cell as text, so I cannot use the date formatting ... (Because I also use Dragon Naturally speaking to dictate dates, and excel date formatting does not work with it)
Can anyone help with how to tell excel what to actually insert, rather than trying to format it afterwards?
2015-06-09 12:23:43
Pryme
To have the macro run every time you open the Excel Workboox, add in ThisWorkbook :
Private Sub Workbook_Open()
...code to run...
End Sub
2014-11-07 16:51:17
awyatt
Yolanda,
There is a link at both the beginning and end of the tip that leads to how to do it in later versions of Excel.
-Allen
2014-11-07 15:12:30
Yolanda
I am working in Excel 2013. How do I specify date format in footers?
Thanks.
2014-09-28 09:57:48
Dave Preston
So simple - thanks. Overcame my issue immediately - thanks
Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2021 Sharon Parq Associates, Inc.
Comments