|
如何将同一个文件夹内所有工作薄内指定工作表汇总
本帖最后由 xdragon 于 2014-3-24 15:36 编辑
- Sub 合并报表()
- Application.EnableEvents = False
- Application.DisplayAlerts = False
- Dim FStr As String, FName As String
- Dim FGO As Object
- Dim irow As Long
- Dim arr, i&
- FStr = Dir(ThisWorkbook.Path & "\*.xls")
- Do Until FStr = ""
- If ThisWorkbook.Path & "" & FStr <> ThisWorkbook.FullName Then
- Set FGO = GetObject(ThisWorkbook.Path & "" & FStr)
- With FGO.Sheets("登记表")
- arr = .Range("A4").CurrentRegion.Value
- For i = 1 To UBound(arr)
- If arr(i, 1) = "" Then Exit For
- Next
- .Range("A4:V" & 1 + i).Copy Cells(Cells(Rows.Count, 1).End(3).Row + 1, 1)
- End With
- FGO.Close
- Set FGO = Nothing
- End If
- FStr = Dir
- Loop
- Application.EnableEvents = True
- Application.DisplayAlerts = True
- End Sub
复制代码
|
|