|
发表于 2012-9-7 17:57
|
显示全部楼层
本楼为最佳答案
本帖最后由 5201314 于 2012-9-7 17:59 编辑
- Sub 合并多工作簿及多工作表()
- Dim MyPath As String, MyFile As String, i As Integer
- Dim Wb As Workbook, arr
- Application.ScreenUpdating = False
- MyPath = ThisWorkbook.Path
- MyFile = Dir(MyPath & "\*.xls")
- Do Until MyFile = ""
- If MyFile <> ThisWorkbook.Name Then
- Set Wb = Workbooks.Open(MyPath & "" & MyFile)
- For i = 1 To Wb.Worksheets.Count
- arr = Sheets(i).UsedRange
- ThisWorkbook.Sheets(i).Range("A" & rows.count).End(xlUp).Offset(1).Resize(UBound(arr), UBound(arr, 2)) = arr
- Next
- Wb.Close
- End If
- MyFile = Dir
- Loop
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|