VBA & Macro Problems

Automatically Add One Year to a Date in Excel with VBA

Phi Hung VoPhi Hung Vo Nov 18, 2026 869 views

Question details

Automatically replace a date entered or edited in cell A1 with the date one year later.

Automatically Add One Year to a Date in Excel with VBA
Product
Microsoft Excel
Device & OS
not provided
Scenario
A user enters or edits a date in cell A1 and wants the same cell to update automatically.
Observed behavior
After a date is entered or edited in A1, the cell should display the corresponding date one year later.
Before you start

Open the workbook in desktop Excel and check that A1 is formatted as a date. You will need to save the workbook as an Excel Macro-Enabled Workbook and enable macros from a trusted source.

Solution 1Recommended

Use a Worksheet_Change macro to update A1

Use this approach when the date must be replaced in the same cell immediately after entry or editing.

The worksheet event checks whether an edit includes A1 and whether its value is a date. It temporarily disables events to prevent the macro's own change from triggering the event again.

1
Open the worksheet module

In desktop Excel, right-click the tab of the worksheet containing A1 and select View Code.

2
Add the event macro

Paste this code into the worksheet code window: Private Sub Worksheet_Change(ByVal Target As Range) If Intersect(Me.Range("A1"), Target) Is Nothing Then Exit Sub If Not IsDate(Me.Range("A1").Value) Then Exit Sub On Error GoTo CleanUp Application.EnableEvents = False Me.Range("A1").Value = DateAdd("yyyy", 1, Me.Range("A1").Value) CleanUp: Application.EnableEvents = True End Sub

3
Save and enable the macro

Choose File > Save As and select Excel Macro-Enabled Workbook (*.xlsm). When reopening the file, enable macros if prompted and if you trust the workbook.

4
Test the date entry

Return to the worksheet and enter a date in A1. For example, entering 3/15/2025 should replace it with 3/15/2026, depending on the cell's date format.

Use a Worksheet_Change macro to update A1
Existing worksheet events: A worksheet module can have only one Worksheet_Change procedure. If one already exists, incorporate the A1 logic into that procedure rather than adding a second event procedure.
Free Microsoft Office alternative

Work with date-based spreadsheets in WPS Office

WPS Office is a free, lightweight alternative with a familiar spreadsheet interface. Its compatibility with Excel formats helps you move everyday spreadsheet work between applications. The Excel VBA event above requires desktop Excel and should not be assumed to run in WPS.

Enter, format, and calculate dates in WPS SpreadsheetsOpen and work with Microsoft Excel formats, including XLSXUse a familiar interface for a smoother move from OfficeWork with a free, lightweight office suite
microsoft office alternative - wps office

Frequently Asked Questions

Can this macro run in Excel for the web?

No. VBA macros do not run in Excel for the web. Open the workbook in desktop Excel and enable macros from a trusted source.

What happens if I enter February 29 in A1?

DateAdd adjusts the result to a valid date in the following year. For example, February 29, 2024 becomes February 28, 2025.

Will the macro update A1 when a formula recalculates?

No. Worksheet_Change responds to edits, not formula recalculation. A different event and approach would be needed for recalculated values.

Why does the date appear as a number after the macro runs?

Select A1, open Format Cells, and choose a Date format. Excel stores dates as serial numbers, so the cell format controls how the result appears.