Written by Allen Wyatt (last updated September 18, 2021)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and 2021
Adding the current date to the header of a worksheet is easy—Excel provides a dialog box where you can specify the placement of the date and use the '&[date]' coding to actually insert the date. But what if you want to insert yesterday's date or tomorrow's date into the header?
That's not nearly as easy. In fact, you can't do it without using a macro. Perhaps the most flexible approach is to write the macro so that it updates the date just before the worksheet is printed, as shown in the following:
Private Sub Workbook_BeforePrint(Cancel As Boolean) ActiveSheet.PageSetup.CenterHeader = _ Format(Date - 1, "mmmm d, yyyy") End Sub
The macro places yesterday's date into the center of the header; you can easily change the CenterHeader property to one of the other available header locations (LeftHeader or RightHeader). You can also change the macro to insert tomorrow's date by changing the "- 1" to "+ 1".
Note:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (10678) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and 2021. You can find a version of this tip for the older menu interface of Excel here: Putting a Different Date in a Header.
Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!
How do you want your page numbers to appear on your printed worksheets? Chances are good that you want them to be ...
Discover MoreYes, Excel can work with Roman numerals, and it even provides a worksheet function that converts to them. How you use ...
Discover MoreExcel won't let you place a formula directly into a footer. You can, however, create a simple macro that will produce the ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2025 Sharon Parq Associates, Inc.
Comments