|
Sub 汇总()
Application.ScreenUpdating = False
Dim MyPath, MyName, AWbName, Wb As Workbook, n, j, arr, brr(1 To 10000, 1 To 8)
[A2:H10000] = ""
MyPath = ActiveWorkbook.Path
MyName = Dir(MyPath & "\" & "*.csv")
AWbName = ActiveWorkbook.Name
Do While MyName <> ""
If MyName <> AWbName Then
Set Wb = Workbooks.Open(MyPath & "\" & MyName)
With Workbooks(1)
arr = ActiveSheet.[a1].CurrentRegion
For i = 2 To UBound(arr)
For j = 2 To 11
n = n + 1
brr(n, 1) = Split(MyName, "-")(0)
brr(n, 2) = Split(MyName, "-")(1)
brr(n, 3) = Split(MyName, "-")(2)
brr(n, 4) = Split(MyName, "-")(3)
brr(n, 5) = Split(Split(MyName, "-")(4), ".")(0)
brr(n, 6) = arr(i, 1)
brr(n, 7) = arr(1, j)
brr(n, 8) = arr(i, j)
Next
Next
n = Workbooks("汇总.xlsm").Sheets("汇总").[a65536].End(3).Row + 1
Workbooks("汇总.xlsm").Sheets("汇总").Range("a" & n).Resize(UBound(brr), 8) = brr
n = 0: Erase brr
Wb.Close False
End With
End If
MyName = Dir
Loop
MsgBox "汇总完毕!", , "报告!"
Application.ScreenUpdating = True
End Sub
给你一段代码自己改下吧.... |
评分
-
1
查看全部评分
-
|