VBA date add

VBA allows you to add time intervals to a date value to get future date value by using DateAdd(interval, number, date) function. If the time interval is negative, the result date is in the past.
-interval can be yyyy (year), m (month), d (day), q (quarter), ww (week), h (hour), n (minute), and s (second).
-number is the interval number to be added to the date value.
-date represents the date value that the number is added to.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
     Dim ProStart, ProEnd
     ProStart = CDate("01-01-2013") ' project start date
     ProEnd = DateAdd("m", 11, ProStart) ' get the project end date by adding 11 months to the project start date
     Range("A1") = "Project start date:" & ProStart
     Range("B1") = "Project end date:" & ProEnd

End Sub

Posted by: Lavy | post date: 02-20-2013 | Subject: VBA for MS Excel

This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.