|
- Sub 汇总()
- Dim Pth As String, Wname As String
- Dim k%, m&, arr
- Dim Wbook As Workbook, Sht As Worksheet
- Application.ScreenUpdating = False
- Pth = ThisWorkbook.Path & Chr(92)
- Wname = Dir(Pth & "*.xls*")
- ActiveSheet.Cells.Clear
- Do While Wname <> ""
- If Wname <> ThisWorkbook.Name Then
- k = k + 1
- Set Wbook = GetObject(Pth & Wname)
- Set Sht = Wbook.Worksheets("sheet1")
- If k = 1 Then
- arr = Sht.Range("A1").CurrentRegion
- Else
- arr = Sht.Range("A1").CurrentRegion.Offset(1)
- End If
- With ActiveSheet
- m = IIf(k = 1, 1, .Range("A1").End(xlDown).Row + 1)
- .Range("A" & m).Resize(UBound(arr, 1), UBound(arr, 2)) = arr
- .Cells(1, UBound(arr, 2) + 1) = "工作簿名称"
- .Cells(IIf(m = 1, 2, m), UBound(arr, 2) + 1).Resize(UBound(arr, 1) - 1) = Wname
- End With
- Wbook.Close False
- End If
- Wname = Dir
- Loop
- Application.ScreenUpdating = True
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|