我输入开始日期和结束日期并执行从 Outlook 导出的代码。
Sub ExportFromOutlook()
Dim dteStart As Date
Dim dteEnd As Date
dteStart = InputBox("What is the start date?", "Export Outlook Calendar")
dteEnd = InputBox("What is the end date?", "Export Outlook Calendar")
Call GetCalData(dteStart, dteEnd)
End Sub
Run Code Online (Sandbox Code Playgroud)
我希望当我按下任何输入框上的“取消按钮”时退出子程序,而不是在 VBA 代码中出现错误来调试它。
I'm having trouble categorizing which week of the month a day belongs to. So, I'm counting a week as first Sunday that passed, even if that week has one or two days, it will be counted as a week. I've attached a photo in order to be more clear in my explanation:
Until now, I have used:
Week 1:
=IF(AND(DAY(A2)>=1;DAY(A2)<=7);(TIME(HOUR(B2);MINUTE(B2);0)-TIME(HOUR(A2);MINUTE(A2);0))*24;0)
Week 2:
=IF(AND(DAY(A2)>=8;DAY(A2)<=14);(TIME(HOUR(B2);MINUTE(B2);0)-TIME(HOUR(A2);MINUTE(A2);0))*24;0)
Week 3:
=IF(AND(DAY(A2)>=15;DAY(A2)<=21);(TIME(HOUR(B2);MINUTE(B2);0)-TIME(HOUR(A2);MINUTE(A2);0))*24;0)
Week 4:
=IF(AND(DAY(A2)>=22;DAY(A2)<=28);(TIME(HOUR(B2);MINUTE(B2);0)-TIME(HOUR(A2);MINUTE(A2);0))*24;0)
And also Week 5 if the month exceeds 28 days or …Run Code Online (Sandbox Code Playgroud)