|
file 20160105 變了文本了, 將第18行代碼改一下便可。
- Sub zz()
- Dim p$, f$, i&, j&, ar, d As Object, k, t
- Application.ScreenUpdating = False
- Application.ShowWindowsInTaskbar = False
- Set d = CreateObject("scripting.dictionary")
- p = ThisWorkbook.Path & "\k"
- f = Dir(p & "*.xlsx")
- Do While f <> ""
- Workbooks.Open (p & f)
- ar = Sheets(1).UsedRange
- Workbooks(f).Close 0
- For i = 2 To UBound(ar)
- For j = 2 To UBound(ar, 2)
- If Not d.exists(ar(i, 2)) Then
- d(ar(i, 2)) = Array(ar(i, 3), ar(i, 4), ar(i, 5), ar(i, 6))
- Else
- t = d(ar(i, 2))
- d(ar(i, 2)) = Array(ar(i, 3), ar(i, 4) + Val(t(1)), ar(i, 5) + Val(t(2)), ar(i, 6) + Val(t(3)))
- End If
- Next
- Next
- f = Dir
- Loop
- If d.Count Then
- k = d.keys: t = d.items
- ReDim ar(1 To d.Count, 1 To 5)
- For i = 0 To UBound(k)
- ar(i + 1, 1) = k(i)
- For j = 0 To UBound(t(i))
- ar(i + 1, j + 2) = t(i)(j)
- Next
- Next
- [b2:f65536] = ""
- [b2].Resize(d.Count, 1).NumberFormat = "@"
- [b2].Resize(d.Count, 5) = ar
- End If
- Application.ScreenUpdating = True
- Application.ShowWindowsInTaskbar = True
- End Sub
复制代码 |
|