现在,很多地方比如学校、社区等在做志愿者排班时,由于志愿者的可提供服务的日期不定,每月的排班是一个难题。
本人简单写了一个小的VBA小文件,完成这个功能。
下载地址:https://download.csdn.net/download/gxchai/22662326
代码如下:
Private Sub btn1_Click()
'判断D2 E2是否能生成日期
If Not IsDate(Cells(2, 5) & "-" & Cells(2, 6) & "-1") Then
MsgBox ("请在E2和F2单元格中填入年份和月份")
Exit Sub
End If
'清空H2-N13
Range("H2:N13").Clear
'取出1号是星期几
weekcol = Weekday(DateSerial(Cells(2, 5), Cells(2, 6), 1))
weekrow = 2
intday = 1
For i = 1 To Day(DateSerial(Cells(2, 5), Cells(2, 6) + 1, 1) - 1)
Cells(weekrow, 7 + weekcol).Value = intday
&