可以使用 For 循环,并判断日期是否在给定的两个日期范围内来实现。以下是示例代码:
Dim startDate As Date
Dim endDate As Date
startDate = #1/1/2021#
endDate = #1/31/2021#
For i = startDate To endDate
If i >= startDate And i <= endDate Then
Debug.Print i
End If
Next i
在这个例子中,我们将 startDate 和 endDate 设置为需要显示日期的范围。For 循环将循环遍历从 startDate 到 endDate 的所有日期。如果日期在这个范围内,则会显示在控制台中。