我试图做以下事情:
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
从 startDate 循环到 endDate 并输出其间的每个日期。在第一次迭代之后 currentDate 等于最小日期 (1899)。我知道还有其他方法可以做到这一点,而且我现在有一种可行的方法,但是为什么会失败?