Given two dates, I’d like to loop through the months. If my start date is 1-Oct-2007 and my end date is 30-Sep-2008, then I’d like my loop counter to be
as it loops through the dates. It might look like this:
For Month = dtStartDate To dtEndDate
x = CallFunction(Month)
Here’s how I do it now, but it doesn’t feel right.
Dim i As Long
Dim dtStartDate As Date, dtEndDate As Date
Dim x As Variant
dtStartDate = #10/1/2007#: dtEndDate = #9/30/2008#
For i = dtStartDate To dtEndDate
If Day(i) = 1 Then
x = CallFunction(Month(i))
Where I’m using this, I know that my dates cover whole months. If that wasn’t the case, Day(i) wouldn’t work.
So what’s the right way?