vba 日历

VBA | 2016-02-24 20:03:06 | 11085次阅读 | 0评
Sub abc()

Dim dm As Variant
Dim m, w, d, r As Integer

y = InputBox("put_year")
m = InputBox("put_month")
d = DateSerial(y, m, 1)
w = Weekday(d)
r = 3

Range("3:10").ClearContents
Cells(1, 1) = y & "-year," & m & "-month"

dm = Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)

If ((y Mod 400 = 0) Or (y Mod 4 = 0 And y Mod 100 <> 0)) Then
dm(1) = 29
End If

For d = 1 To dm(m - 1)
Cells(r, w) = d
w = w + 1
If w > 7 Then
w = 1
r = r + 1
End If
Next
End Sub



日歷.xls (下载178次,上传于2016-02-24 20:16:51)
博友评论,共0条
浏览152427次