|
发表于 2012-10-28 17:38
|
显示全部楼层
本楼为最佳答案
- Sub Macro1()
- Dim MyPath$, MyName$, lc&, m&, sh As Worksheet
- Set sh = ActiveSheet
- MyPath = ThisWorkbook.Path & ""
- MyName = Dir(MyPath & "*.xls")
- Application.ScreenUpdating = False
- sh.UsedRange.Clear
- Do While MyName <> ""
- If MyName <> ThisWorkbook.Name Then
- m = m + 1
- With GetObject(MyPath & MyName)
- With .Sheets(1)
- If m = 1 Then lc = 1 Else lc = .[a1].CurrentRegion.Columns.Count + 1
- .[a1].CurrentRegion.Copy sh.Cells(1, lc)
- End With
- .Close False
- End With
- End If
- MyName = Dir
- Loop
- Application.ScreenUpdating = True
- MsgBox "完毕"
- End Sub
-
复制代码 |
|