大家好,今天我们就用上一篇文章中的VBA函数来完成一个简短的日历程序。
我们先上代码,然后再一点点去解析代码逻辑。
Sub 日历()
Dim WkName As String
Dim i, j, k, l As Long
Dim strStar As Date
Dim strEnd As Date
strStar = InputBox("日历编辑起始日期", "日历编辑", #1/1/2017#)
If strStar <> False Then
strEnd = InputBox("日历编辑终止日期", "日历编辑", #5/1/2017#)
If strEnd <> False Then
WkName = WeekdayName(Weekday(Format(strStar, "yyyy/mm/dd")))
Range("A1") = Year(strStar) & "年" & Month(strStar) & "月"
Range("A1:G1").Merge
Range("A1:G1").HorizontalAlignment = xlHAlignCenter
Range("A2:G2") = Array("星期日", "星期一", "星期二", &#