|
合并同一文件夹下多个工作簿汇总到一个工作表中
Sub gj23w98()
Dim brr(1 To 99999, 1 To 14)
Application.ScreenUpdating = False
p = ThisWorkbook.Path & "\"
f = Dir(p & "*.xls*")
Do While f <> ""
If f <> ThisWorkbook.Name Then
Set wb = Workbooks.Open(p & f)
Arr = wb.Sheets(1).[b4].CurrentRegion
For i = 2 To UBound(Arr)
m = m + 1
brr(m, 1) = Split(wb.Name, ".xlsx")(0)
brr(m, 2) = wb.Sheets(1).Name
For j = 1 To UBound(Arr, 2)
brr(m, j + 2) = Arr(i, j)
Next
Next
wb.Close False
End If
f = Dir
Loop
If m Then
[a3].CurrentRegion.Offset(1).ClearContents
[a4].Resize(m, 14) = brr
End If
Application.ScreenUpdating = True
MsgBox "OK!"
End Sub |
|