vba 日历

作者在 2016-02-24 20:03:06 发布以下内容
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



VBA | 阅读 12939 次
文章评论,共0条
游客请输入验证码
浏览239387次
最新评论