VBA Excel 循环遍历一年中的所有日子
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15812116/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 20:25:46 来源:igfitidea点击:
VBA Excel loop through all days in a year
提问by Martin Carlsson
In Excel VBA:
在 Excel VBA 中:
How do I loop through all days in a given date range?
如何遍历给定日期范围内的所有天数?
'2013-01-01' to '2013-01-03' should give:
'2013-01-01' 到 '2013-01-03' 应该给出:
2013-01-01
2013-01-02
2013-01-03
回答by John Bustos
This should at least show you how to get started with what you're trying to do:
这至少应该向您展示如何开始您正在尝试做的事情:
Sub test()
Dim StartDate As Date
Dim EndDate As Date
Dim DateLooper As Date
StartDate = #1/1/2013#
EndDate = #12/31/2013#
For DateLooper = StartDate To EndDate
MsgBox (DateLooper)
Next DateLooper
End Sub