|
|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub 出勤情况()
Application.ScreenUpdating = False
Dim ar As Variant
Dim i As Long, r As Long
Dim br()
Application.DisplayAlerts = False
For Each sh In Sheets
If sh.Name <> "出勤表" Then
sh.Delete
End If
Next sh
Application.DisplayAlerts = True
With Sheets("出勤表")
r = .Cells(Rows.Count, 2).End(xlUp).Row
y = .Cells(2, Columns.Count).End(xlToLeft).Column
If r < 3 Or y < 3 Then MsgBox "出勤工作表为空!": End
ar = .[a1].Resize(r, y)
End With
For j = 3 To UBound(ar, 2)
n = 0
ReDim br(1 To UBound(ar), 1 To 3)
If ar(2, j) <> "" Then
For i = 3 To UBound(ar)
If ar(i, j) = "出勤" Then
n = n + 1
br(n, 1) = n
br(n, 2) = ar(i, 2)
End If
Next i
If n > 0 Then
Set sht = Sheets.Add(after:=Sheets(Sheets.Count))
With sht
.Name = Format(ar(2, j), "yyyy-m-d")
.[a1] = "日期:" & Format(ar(2, j), "yyyy-m-d")
With .[a2].Resize(1, 3)
.Value = Array("序号", "姓名", "签名")
.Borders.LineStyle = 1
End With
With .[a3].Resize(n, 3)
.Value = br
.Borders.LineStyle = 1
End With
End With
End If
End If
Next j
Application.ScreenUpdating = True
MsgBox "ok!"
End Sub
|
|