|
Sub 按钮1_Click()
dt = InputBox("请输入考勤表年月信息(年四位月两位如:202301)", "输入年月", Format(Date, "yyyymm"))
If Len(dt) <> 6 Or Not VBA.IsNumeric(dt) Then
MsgBox "输入年月无效"
Exit Sub
End If
Application.ScreenUpdating = False
Sheets("模板").Copy after:=Sheets(1)
Sheets(2).Name = dt
[b2] = " 工地人员" & Left(dt, 4) & "年" & Right(dt, 2) & "月出勤统计表"
Rows("3:4").Font.ColorIndex = 0
d = CDate(Left(dt, 4) & "-" & Right(dt, 2) & "-1")
For j = 1 To 31
If Month(d) = Month(d + j - 1) Then
Cells(3, j + 2) = j
Z = Right(Format(d + j - 1, "AAA"), 1)
Cells(4, j + 2) = Z
If "六" = Z Then
Cells(3, j + 2).Resize(2, 2).Font.ColorIndex = 3
End If
Else
Exit For
End If
Next j
For Each shp In ActiveSheet.Shapes
shp.Delete
Next shp
Application.ScreenUpdating = True
End Sub
|
|