这儿有肥猫 发表于 2014-9-24 15:12
是的话,见附件,
如果还不对,请对附件中进行手动计算核对,应该不太可能出错
您好,你给我的代码,如果表格的列(横)项到ai,竖项到75(竖项已改),下面的编码怎么改呀?
Sub a()
Application.ScreenUpdating = False
[d7:ai75].ClearContents
Dim arr, brr, crr, mypath$, myname$, i&, j&, rng, dic As Object, s&
Set dic = CreateObject("scripting.dictionary")
mypath = ThisWorkbook.Path
mypath = Left(mypath, Len(mypath) - 5) & "\配方档案\"
arr = Range("b7:ai75")
ReDim crr(1 To UBound(arr), 1 To 5)
For i = 4 To 8
myname = ""
myname = Dir(mypath & Cells(4, i) & Cells(5, i) & Cells(6, i) & ".xls")
If myname <> "" Then
With GetObject(mypath & myname)
brr = .Sheets(1).Range("c13").CurrentRegion
For j = 1 To UBound(brr)
dic(brr(j, 2)) = brr(j, 4) + dic(brr(j, 2))
Next
.Close False
End With
For s = 1 To UBound(arr)
crr(s, i - 3) = dic(arr(s, 1))
Next
End If
dic.RemoveAll
Erase brr
Next
[d7].Resize(UBound(crr), UBound(crr, 2)) = crr
Set dic = Nothing
Application.ScreenUpdating = False
End Sub
|