Kayleigh
Member
- Local time
- Today, 17:36
- Joined
- Sep 24, 2020
- Messages
- 709
Hi,
Have a simple piece of code which doesn't seem to be working. It should be iterating through all the dates from specified start date until end date. However when I try running, I don't seem to be entering the loop. Where have I gone wrong?
Have a simple piece of code which doesn't seem to be working. It should be iterating through all the dates from specified start date until end date. However when I try running, I don't seem to be entering the loop. Where have I gone wrong?
Code:
'Iterate through dates
stDate = Format(CDate(Me.txtDateStart), "mm/dd/yyyy")
enDate = Format(CDate(Me.txtDateEnd), "mm/dd/yyyy")
i = 1
d = stDate
Do While d <= enDate
Debug.Print "Iteration " & i & ":" & vbTab & d
'Some actions
d = DateAdd("d", 1, d)
If d > enDate Then
Exit Do
End If
i = i + 1
Loop