|
Sub 练习()
Dim sr$, fl$, wb As Workbook, sht As Worksheet
t = Timer
Application.ScreenUpdating = False
sr = ThisWorkbook.Path
Set sht = ThisWorkbook.Sheets("验收")
sht.UsedRange.Clear
With sht
For i = 1 To 50
fl = sr & "\数据" & i & ".xls"
Set wb = Workbooks.Open(fl)
arr = wb.Sheets(1).Range("a2:d12")
n = UBound(arr): m = UBound(arr, 2)
If i < 26 Then
x = 2
If i = 1 Then y = 1 Else y = .Cells(x, "iv").End(1).Column + 1
.Cells(x, y).Resize(n, m) = arr
r = .[a65536].End(3).Row + 3
Else
x = r
If i = 26 Then y = 1 Else y = .Cells(x, "iv").End(1).Column + 1
.Cells(x, y).Resize(n, m) = arr
End If
x = x - 1
.Cells(x, y).Resize(1, m).Merge
.Cells(x, y) = "数据" & i
wb.Close 1
Next i
With .UsedRange
.Font.Size = 10
.Columns.AutoFit
.HorizontalAlignment = xlCenter
End With
End With
Application.ScreenUpdating = True
MsgBox Format(Timer - t, "0.00秒")
End Sub |
|