|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub 数据汇总()
Application.ScreenUpdating = False
Dim ar()
ReDim ar(1 To 50000, 1 To 4)
lj = ThisWorkbook.Path & "\"
f = Dir(lj & "*.xls*")
Do While f <> ""
If f <> ThisWorkbook.Name Then
Set wb = Workbooks.Open(lj & f, 0)
n = n + 1
ar(n, 1) = Split(wb.Name, ".")(0)
With wb.Worksheets(1)
For i = 4 To 6
ar(n, i - 2) = .Cells(i, 1)
Next i
End With
wb.Close False
End If
f = Dir
Loop
If n = "" Then MsgBox "没有需要汇总的数据!": End
With ActiveSheet
.UsedRange = Empty
.[a2].Resize(n, 4) = ar
End With
Application.ScreenUpdating = True
MsgBox "ok!"
End Sub
|
|