|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub gj23w98()
tms = Timer
Application.ScreenUpdating = False: Application.DisplayAlerts = False
Dim arr(), crr(1 To 1000, 1 To 3)
Sheet1.[a1].CurrentRegion.Offset(1).ClearContents
mypath = ThisWorkbook.Path & "\工资表\"
myfile = Dir(mypath, vbDirectory)
Do While myfile <> ""
If myfile <> "." And myfile <> ".." Then
If (GetAttr(mypath & myfile) And vbDirectory) = vbDirectory Then
m = m + 1
ReDim Preserve arr(m)
arr(m) = mypath & myfile & "\"
End If
End If
myfile = Dir
Loop
For j = 1 To m
myfile = Dir(arr(j) & "营运中心.xlsx")
While myfile <> ""
Set wb = CreateObject(arr(j) & myfile)
With wb.Sheets(1)
brr = .[a1].CurrentRegion
For i = 4 To UBound(brr)
If InStr(brr(i, 1), "何飞燕") Then
n = n + 1
crr(n, 1) = brr(i, 1)
crr(n, 2) = brr(i, 21)
crr(n, 3) = Split(arr(j), "\")(6)
End If
Next
End With
wb.Close
myfile = Dir()
Wend
Next
[a2].Resize(n, 3) = crr
Set wb = Nothing
Application.ScreenUpdating = True: Application.DisplayAlerts = True
MsgBox Format(Timer - tms, "何飞燕实发工资并查询成,耗时:0.00秒"), 64, "温馨提示"
End Sub
|
|