|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
你都没有回答我在楼上给你的提问,貌似很没有诚意哦,小妹。另外,你的数据源的工作表中某些单元格有错误公式,错误公式在vba数组中是无法容纳的,现在我对其进行了特别处理:错误的公式一律标为0.请看汇总结果,看看是否符合要求。另外,这里有一个也是类似的,请参考:http://club.excelhome.net/thread-1166507-1-1.html- Sub L()
- Dim Mypath$, Myname$, str$, sht As Worksheet, i%, Arr(1 To 10000, 1 To 15), drow%, drow1%, Brr, k%, j%, d, mmax%
- mmax = 1: i = 1
- Set d = CreateObject("scripting.dictionary")
- On Error Resume Next
- sht = ThisWorkbook.Worksheets("sheet1")
- Mypath = ThisWorkbook.Path & "\IE库"
- Myname = Dir(Mypath & "*.xls")
- Application.ScreenUpdating = False
- Do While Myname <> ""
- If Myname <> ThisWorkbook.Name Then
- ' MsgBox Myname
- With GetObject(Mypath & Myname)
- With .Worksheets("开料")
- Brr = .Range("e3:e9")
- Arr(i, 1) = Left(Myname, Len(Myname) - 4)
- Arr(i, 2) = IIf(IsError(.Cells(3, 5)), 0, .Cells(3, 5))
- Arr(i, 3) = IIf(IsError(.Cells(4, 5)), 0, .Cells(4, 5))
- Arr(i, 4) = IIf(IsError(.Cells(5, 5)), 0, .Cells(5, 5))
- Arr(i, 5) = IIf(IsError(.Cells(6, 5)), 0, .Cells(6, 5))
- Arr(i, 6) = IIf(IsError(.Cells(7, 5)), 0, .Cells(7, 5))
- Arr(i, 7) = IIf(IsError(.Cells(8, 5)), 0, .Cells(8, 5))
- Arr(i, 8) = IIf(IsError(.Cells(9, 5)), 0, .Cells(9, 5))
- Arr(i, 9) = Arr(i, 2) + Arr(i, 3) + Arr(i, 4) + Arr(i, 5) + Arr(i, 6) + Arr(i, 7) + Arr(i, 8)
- i = i + 1
- mmax = i
- End With
- .Close False
- End With
- End If
- Myname = Dir
- Loop
- With ThisWorkbook.Worksheets("sheet1")
- .Range("a3:i65536").ClearContents
- .Cells(3, 1).Resize(mmax, 9) = Arr
- End With
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|