VBA & Macro Problems

Add Days to an Excel Header or Footer Date with VBA

Adam DavisAdam Davis Dec 2, 2026 868 views

Question details

Calculate a future date and display it in an Excel worksheet header or footer.

Add Days to an Excel Header or Footer Date
Product
Microsoft Excel
Device & OS
not provided
Scenario
A user wants a header or footer to show a date a set number of days after the current date.
Observed behavior
Excel's built-in &[Date] field displays the current date but cannot add days by itself.
Before you start

Open the workbook in desktop Excel and identify the worksheet and header or footer position you want to update. Save the workbook as an Excel Macro-Enabled Workbook (.xlsm) if you want to keep VBA code.

Solution 1Recommended

Use VBA to insert a future date in the header or footer

Use a macro to calculate a date offset and write the result to the active worksheet's page setup.

The &[Date] field cannot perform date arithmetic. The macro writes a formatted date as static text, so run it again whenever you need the date refreshed.

1
Open the VBA editor

In desktop Excel, open the Developer tab and select Visual Basic. If the Developer tab is hidden, enable it in Excel's ribbon settings.

2
Insert a module

In the VBA editor, select your workbook in the Project pane, then choose Insert > Module.

3
Add the macro

Paste this code into the module: Sub SetFutureHeaderDate() ActiveSheet.PageSetup.CenterHeader = Format(Date + 3, "m/d/yyyy") End Sub Change 3 to the number of days you want to add. To use the center footer instead, replace CenterHeader with CenterFooter.

4
Run and check the result

Return to Excel, select the target worksheet, and choose Developer > Macros. Select SetFutureHeaderDate and click Run, then open File > Print to check the header or footer preview.

Use VBA to insert a future date in the header or footer
Refresh before printing: The inserted date does not update automatically. Run the macro again before printing if the current date has changed.
Free Microsoft Office alternative

Edit spreadsheet headers and footers with WPS Office

WPS Office is a free, lightweight alternative with a familiar spreadsheet interface for opening and editing Office files. It can help you work with headers and footers, but it does not fix Excel's date-field limitation; VBA support can vary by WPS version.

Edit spreadsheet headers and footers in a familiar interfaceOpen and work with Microsoft Excel XLSX filesUse a free, lightweight office suiteMove between common Office documents with a familiar interface
microsoft office alternative - wps office

Frequently Asked Questions

Can I add days directly to Excel's &[Date] header field?

No. The &[Date] field displays the current date and does not support arithmetic. Use VBA to calculate the offset and write the result to PageSetup.

How do I put the future date in the footer instead?

In the macro, replace ActiveSheet.PageSetup.CenterHeader with ActiveSheet.PageSetup.CenterFooter, then run the macro on the target worksheet.

Will the VBA-generated date update automatically tomorrow?

No. The macro inserts formatted text rather than a live date field. Run it again before printing to calculate a fresh date.

Why should I save the workbook as an XLSM file?

The .xlsm format retains VBA code. Choose File > Save As and select Excel Macro-Enabled Workbook to keep the macro in the workbook.