|
Sub hebing()
Application.ScreenUpdating = False
Set sh = ThisWorkbook.Worksheets(1)
sh.[a1].CurrentRegion.Clear
Dim arr()
Dim rng As Range
ReDim arr(1 To 10000, 1 To 50)
f = Dir(ThisWorkbook.Path & "\*.xls*")
Do While f <> ""
If f <> ThisWorkbook.Name Then
m = m + 1
Set wb = Workbooks.Open(ThisWorkbook.Path & "\" & f, 0)
With wb.Worksheets("柜体开料清单新")
If m = 1 Then
Set rng = .Rows(1)
rng.Copy sh.[a1]
End If
ar = .[a1].CurrentRegion
For i = 2 To UBound(ar)
If Trim(ar(i, 1)) <> "" Then
n = n + 1
For j = 1 To UBound(ar, 2)
arr(n, j) = ar(i, j)
Next j
End If
Next i
End With
wb.Close False
End If
f = Dir
Loop
sh.[a2].Resize(n, UBound(arr, 2)) = arr
Application.ScreenUpdating = True
MsgBox "ok!"
End Sub
|
|