文件名称:用excel vba写的日历代码
文件大小:26KB
文件格式:XLSM
更新时间:2014-12-03 12:57:20
excel vba 日历
用excel vba写的日历部分代码如下 Private Sub Calendar(ByVal iyear, ByVal imonth) For icol = 1 To 7 For irow = 3 To 8 Cells(irow, icol) = "" Next Next iday = DateSerial(iyear, imonth, 1) '取得相应年月第一天的日期 irow = 3 icol = Weekday(iday) '计算该天是星期几 Do Cells(irow, icol) = Day(iday) '在单元格填入日期 If Weekday(iday) = vbSaturday Then '星期六则的换行 irow = irow + 1 icol = 1 Else icol = icol + 1 End If iday = DateAdd("d", 1, iday) '日期递增 Loop While (Day(iday)) <> 1 End Sub