|
- Sub 工作薄汇总() '可汇总薄名和工作表名
- Dim MyPath$, MyName$, sh As Worksheet, sht As Worksheet, m&, Brr(1 To 50000, 1 To 20)
- Dim n%, i%, j%, Crr
- Application.ScreenUpdating = False
- Set sh = ActiveSheet
- MyPath = ThisWorkbook.Path & "\明细"
- MyName = Dir(MyPath & "*.xls?")
- [E15].CurrentRegion.Offset(1).Clear
- Do While MyName <> ""
- If MyName <> ThisWorkbook.Name Then
- With GetObject(MyPath & MyName)
- For Each sht In .Sheets
- n = sht.Cells(sht.Rows.Count, 5).End(xlUp).Row - 1
- Crr = sht.[e16].Resize(n, 18)
- If n >= 15 Then
- For i = 1 To UBound(Crr)
- m = m + 1
- Brr(m, 1) = MyName: Brr(m, 2) = sht.Name
- For j = 1 To UBound(Crr, 2)
- Brr(m, j + 2) = Crr(i, j)
- Next
- Next
- End If
- Next
- .Close False
- End With
- End If
- MyName = Dir
- Loop
- sh.[e16].Resize(m, 20) = Brr
- Application.ScreenUpdating = True
- MsgBox "ok"
- End Sub
复制代码 |
|