|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 lsc900707 于 2017-3-22 17:15 编辑
- <div class="blockcode"><blockquote>Option Explicit
- Sub test()
- Dim myPath$, MyName$, sh As Worksheet, t#
- Dim Arr, brr, i&, j&, m&, n&
- t = Timer
- myPath = ThisWorkbook.Path & ""
- MyName = Dir(myPath & "*.xls")
- Application.ScreenUpdating = False
- ReDim brr(1 To 100000, 1 To 50)
- Do While MyName <> ""
- If MyName <> ThisWorkbook.Name Then
- n = n + 1
- Set sh = GetObject(myPath & MyName).Sheets("Sheet1")
- Arr = sh.[A1].CurrentRegion
- Workbooks(MyName).Close False
- For i = 3 To UBound(Arr)
- If Arr(i, 8) Like "农民工*" Then
- m = m + 1
- For j = 1 To UBound(Arr,2)
- brr(m, j) = Arr(i, j)
- Next
- End If
- Next
- End If
- MyName = Dir
- Loop
- Set sh = Nothing
- With Sheet1
- .Rows("1:3000").ClearContents
- .[A1].Resize(2, UBound(Arr, 2)).Value = Arr
- .[a3].Resize(m, UBound(brr, 2)).Value = brr
- End With
- Application.ScreenUpdating = True
- MsgBox "汇总完成!汇总了:" & n & "个工作表;共有:" & m & "行数据。" & vbCr & "用时:" & Format(Timer - t, "0.00") & "秒", vbInformation
- End Sub
复制代码
|
|