|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub 取数()
- Sheet1.Range("a1").CurrentRegion.Offset(2).ClearContents
- Application.ScreenUpdating = False
- Dim wb As Workbook, Sht As Worksheet
- Dim arr(), i
- tim = Timer
- sa = Array(2, 3, 4, 8, 8)
- sb = Array(8, 11, 3, 12, 14)
- f = Dir(ThisWorkbook.Path & "\*.xls")
- Do While f <> ""
- If f <> ThisWorkbook.Name Then
- Set wb = Workbooks.Open(ThisWorkbook.Path & "" & f)
- n = n + 1
- ReDim Preserve arr(1 To 5, 1 To n)
- For i = 0 To 4
- If i = 1 Then
- arr(2, n) = Mid(wb.Sheets(1).Cells(sa(i), sb(i)), 4, 4)
- Else
- arr(i + 1, n) = wb.Sheets(1).Cells(sa(i), sb(i))
- End If
- Next
- wb.Close False
- End If
- f = Dir
- Loop
- Sheet1.Range("A:A").NumberFormatLocal = "@"
- Sheet1.[A3].Resize(n, 5).Value = Application.Transpose(arr)
- MsgBox Format(Timer - tim, "共汇总了 " & n & " 个工作薄,耗时:0.00秒"), 64, "温馨提示"
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|