I was trying to do the following:
startDate = Date
endDate = DateAdd("yyyy", -1, startDate)
currentDate = startDate
Do While DateDiff("d", endDate, currentDate) <> 0
With ActiveSheet.Range("A1")
.Offset(i, 0).Value = currentDate
End With
currentDate = DateAdd("d", -1, currentDate)
i = i + 1
Loop
to loop from startDate to endDate and output every date in between. After the first iteration currentDate equals the minimum date (1899).
I know there are other ways to do this and I have a way that works now, but why does this fail?
Your code worked fine for me
Yoo could actually avoid the loop by either
code