|
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
现在需要删除arr赋值后其中三列连续数据,请问怎么实现?另外如果其中某个arr复制区域没有数据,就会导致汇总错行,怎么解决? |
|