|
Sub 合并()
Application.ScreenUpdating = False
Dim ar As Variant
Dim br()
ReDim br(1 To 200000, 1 To 16)
lj = ThisWorkbook.Path & "\"
f = Dir(lj & "*.xls*")
Set sh = ThisWorkbook.Sheets(1)
t = Timer
sh.[a1].CurrentRegion.Clear
Do While f <> ""
If f <> ThisWorkbook.Name Then
m = m + 1
Set wb = Workbooks.Open(lj & f, 0)
With wb.Worksheets(1)
r = .Cells(Rows.Count, 1).End(xlUp).Row
If m = 1 Then
.Range("a1:p" & r).Copy sh.[a1]
Else
rs = sh.Cells(Rows.Count, 1).End(xlUp).Row + 1
.Range("a2:p" & r).Copy sh.Cells(rs, 1)
End If
End With
wb.Close False
End If
f = Dir
Loop
Application.ScreenUpdating = True
MsgBox "耗时:" & Format(Timer - t, "0.00") & "秒!"
End Sub
|
|