|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub test()
Dim arB(1 To 10000, 1 To 6)
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, 44)
arB(n, 4) = arB(n, 4) + arA(i, 48)
If InStr(arA(i, 13), "自离") = 0 Then
arB(n, 5) = arB(n, 5) + arA(i, 44)
arB(n, 6) = arB(n, 6) + 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, 6) = arB
End With
Application.ScreenUpdating = True
MsgBox "ok!"
End Sub |
评分
-
3
查看全部评分
-
|