|
Sub test()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim Arr, Brr(), Mpath$, Mfile$, i%, n%
Mpath = ThisWorkbook.Path & "\"
Mfile = Dir(Mpath & "*.xls")
Do
If Mfile <> ThisWorkbook.Name Then
Set wb = GetObject(Mpath & Mfile)
Arr = wb.Sheets(1).[a1].CurrentRegion
If UBound(Arr) >= 2 Then
For i = 2 To UBound(Arr)
n = n + 1
ReDim Preserve Brr(1 To 3, 1 To n)
Brr(1, n) = Arr(i, 1)
Brr(2, n) = "'" & Mid(Mfile, 1, 2)
Brr(3, n) = Mid(Split(Mfile, ".xls")(0), 3)
Next
End If
wb.Close False
End If
Mfile = Dir
Loop Until Mfile = ""
[a2].Resize(n, 3) = Application.Transpose(Brr)
Erase Arr, Brr
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub |
|