|
- Sub test()
- Dim r&, i&, m&
- Dim arr, brr(1 To 10000, 1 To 6)
- Dim wb As Workbook
- Dim ws As Worksheet
- Dim mypath$, myname$
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- mypath = ThisWorkbook.Path & ""
- myname = Dir(mypath & "*.xlsx")
- m = 0
- Do While myname <> ""
- If myname <> ThisWorkbook.Name Then
- Set wb = GetObject(mypath & myname)
- With wb
- With .Worksheets(1)
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- arr = .Range("a2:x" & r)
- For i = 1 To UBound(arr)
- m = m + 1
- brr(m, 1) = arr(i, 2)
- brr(m, 2) = arr(i, 3)
- brr(m, 3) = arr(i, 5)
- brr(m, 4) = arr(i, 6)
- brr(m, 5) = arr(i, 7)
- brr(m, 6) = arr(i, 12)
- Next
- End With
- .Close False
- End With
- End If
- myname = Dir
- Loop
- With Worksheets("sheet1")
- .UsedRange.Offset(1, 0).ClearContents
- .Range("a2").Resize(m, UBound(brr, 2)) = brr
- End With
- End Sub
复制代码 |
|