You can use the DateDiff(interval, date1,date2[,firstdayofweek[,firstweekofyear]]) function to calculate the number
of days, months, weeks, quarters, hours, minutes, or second between two date values (date1 and date2).
-interval can be yyyy (year), m (month), d (day), q (quarter), ww (week), h (hour), n (minute), and s (second).
-date 1 is the first date.
-date2 is the second date.
-firstdayofweek (optional) specifies the start day of the week:
+1 Sunday (default)
-firstweekofyear(optional) specifies the first week of the year:
+1 Start with the week in which January 1 occurs (default)
+2 Start with the first week that has at least four days in the new year
+3 Start with the first full week of the year
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim ProStart, ProEnd
ProStart = CDate("01-01-2013")
ProEnd = CDate("02-03-2014")
Range("C1") = DateDiff("d", ProStart, ProEnd) 'calculate the difference( in day) between ProStart and ProEnd
Posted by: Lavy | post date: 02-20-2013 | Subject: VBA for MS Excel