Loading
Excel.Tips.Net ExcelTips (Menu Interface)

Specifying Date Formats in Headers

Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Specifying Date Formats in Headers.

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.

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.

Related Tips:

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

 

Leave your own comment:

*Name:
Email:
  Notify me about new comments ONLY FOR THIS TIP
Notify me about new comments ANYWHERE ON THIS SITE
Hide my email address
*Text:
*What is 5+3 (To prevent automated submissions and spam.)
 
 
           Commenting Terms

Comments for this tip:

Piecevcake    26 Jul 2016, 10:39
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?
piecevcake    26 Jul 2016, 10:37
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?
Pryme    09 Jun 2015, 12:23
To have the macro run every time you open the Excel Workboox, add in ThisWorkbook :

Private Sub Workbook_Open()
...code to run...
End Sub
awyatt    07 Nov 2014, 16:51
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
Yolanda    07 Nov 2014, 15:12
I am working in Excel 2013. How do I specify date format in footers?
Thanks.
Dave Preston    28 Sep 2014, 09:57
So simple - thanks. Overcame my issue immediately - thanks
 
 

Our Company

Sharon Parq Associates, Inc.

About Tips.Net

Contact Us

 

Advertise with Us

Our Privacy Policy

Our Sites

Tips.Net

Beauty and Style

Cars

Cleaning

Cooking

DriveTips (Google Drive)

ExcelTips (Excel 97–2003)

ExcelTips (Excel 2007–2016)

Gardening

Health

Home Improvement

Money and Finances

Organizing

Pests and Bugs

Pets and Animals

WindowsTips (Microsoft Windows)

WordTips (Word 97–2003)

WordTips (Word 2007–2016)

Our Products

Helpful E-books

Newsletter Archives

 

Excel Products

Word Products

Our Authors

Author Index

Write for Tips.Net

Copyright © 2016 Sharon Parq Associates, Inc.