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
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: