|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub test()
Dim brr(1 To 100000, 1 To 10)
p = ThisWorkbook.Path & "\"
f = Dir(p & "*.xls")
Application.ScreenUpdating = False
Do While f <> ""
If f <> ThisWorkbook.Name Then
Set sht = Workbooks.Open(p & f).Sheets(1)
Arr = sht.[a1].CurrentRegion
Workbooks(f).Close False
For i = 2 To UBound(Arr) - 1
m = m + 1
brr(m, 1) = Split(f, ".")(0)
For j = 2 To 10
brr(m, j) = Arr(i, j - 1)
Next
Next
End If
f = Dir
Loop
Set sht = Nothing
With Sheet1
.Cells.ClearContents
[a1] = "来源": .[b1].Resize(1, UBound(Arr, 2)) = Arr
.[a2].Resize(m, UBound(brr, 2)) = brr
End With
Application.ScreenUpdating = True
MsgBox "合并完成!"
End Sub
|
|