Share via

How to write a script to add 14 days

SteveD 145 Reputation points
2026-02-09T05:08:56.92+00:00

Hello from Steve

Please how do I write a Macro that would add 14 days

for example In Cell J2 I have10-February add 14 days to become 24-February

Microsoft 365 and Office | Excel | For home | Windows
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. SteveD 145 Reputation points
    2026-02-09T05:46:47.84+00:00

    Hello Francisco

    Firstly Thank you

    (overwriting 10-February with 24-February), in Cell J2

    Just on Cell J2


  2. Francisco Montilla 30,070 Reputation points Independent Advisor
    2026-02-09T05:43:15.2033333+00:00

    Hello,

    I need to clarify how you want the result to be handled to ensure this fits your workflow.

    • Do you want the date in cell J2 to be permanently replaced by the calculated date (overwriting 10-February with 24-February), or do you simply want to see the new date in a different cell next to it?
    • Also, do you plan to run this on a whole column of dates or strictly just on cell J2?
    0 comments No comments

  3. Q&A Assist
    2026-02-09T05:09:03.85+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    To write a Macro in Excel that adds 14 days to a specified date, you can use the DateAdd function in VBA (Visual Basic for Applications). Here’s a simple example of how you can achieve this:

    Sub AddDays()
        Dim FirstDate As Date  ' Declare variable for the initial date
        Dim NewDate As Date    ' Declare variable for the new date
        FirstDate = InputBox("Enter a date (e.g., 10-February)")
        NewDate = DateAdd("d", 14, FirstDate)  ' Add 14 days to the first date
        MsgBox "New date: " & NewDate  ' Display the new date
    End Sub
    

    In this script:

    • The user is prompted to enter a date.
    • The DateAdd function is used to add 14 days to the entered date.
    • The result is displayed in a message box.

    Make sure to run this Macro in the VBA editor within Excel to see the results.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.