|
结合新附件要求,修改代码如下:
Sub test()
Dim arB(1 To 10000, 1 To 10)
p = ThisWorkbook.Path & "\"
f = Dir(p & "*.xlsx")
Application.ScreenUpdating = False
Do While f <> ""
If f <> ThisWorkbook.Name Then
Set wb = Workbooks.Open(p & f)
With wb.Sheets("工资表")
r = .Cells(.Rows.Count, 1).End(3).Row
arA = .Range("a1:av" & r)
n = n + 1
arB(n, 1) = n
arB(n, 2) = Replace(Split(f, ".")(0), "工资表", "")
For i = 2 To UBound(arA)
arB(n, 3) = arB(n, 3) + arA(i, 40)
arB(n, 4) = arB(n, 4) + arA(i, 48)
If InStr(arA(i, 13), "自离") = 0 Then
For j = 5 To 9
arB(n, j) = arB(n, j) + arA(i, j + 35)
Next
arB(n, 10) = arB(n, 10) + arA(i, 48)
End If
Next
End With
wb.Close False
End If
f = Dir
Loop
Set wb = Nothing
With Sheet1
.[a1].CurrentRegion.Offset(1).ClearContents
.[a2].Resize(n, 10) = arB
End With
Application.ScreenUpdating = True
MsgBox "ok!"
End Sub |
评分
-
2
查看全部评分
-
|