|
huagnzhailing 发表于 2012-7-1 10:14
赵老师,您优化的程序,这两天在使用中发现以下问题,可否再帮忙看看什么原因,非常感谢
当在B列的输入 ... - Sub Macro1() '1个字典
- Dim ar, br(), i&, j&, cr, dr, er, tt
- tt = Timer
- Dim d As Object
- Set d = CreateObject("Scripting.Dictionary")
- Range("E6:E65536,J6:n65536").ClearContents '修改
- lr = Range("B65536").End(xlUp).Row
- If lr < 6 Then Exit Sub
- ar = Range("B6:c" & lr)
- ReDim br(1 To UBound(ar), 1 To 5)
- cr = Sheets("数据库.在途量").Range("e4:j" & Sheets("数据库.在途量").[j65536].End(3).Row)
- dr = Sheets("数据库.IQC在检").Range("a4:c" & Sheets("数据库.IQC在检").[c65536].End(3).Row)
- er = Sheets("数据库.森田总表").Range("c4:s" & Sheets("数据库.森田总表").[s65536].End(3).Row)
- For i = 1 To UBound(cr)
- d(cr(i, 1)) = d(cr(i, 1)) + cr(i, 6)
- Next
- For i = 1 To UBound(dr)
- d("A" & dr(i, 1)) = dr(i, 3)
- Next
- For i = 1 To UBound(er)
- If Not d.exists("B" & er(i, 1)) Then d("B" & er(i, 1)) = er(i, 12)
- If Not d.exists("C" & er(i, 1)) Then d("C" & er(i, 1)) = er(i, 17)
- If Not d.exists("D" & er(i, 1)) Then d("D" & er(i, 1)) = er(i, 14)
- d("E" & er(i, 1)) = er(i, 5)
- Next
- For i = 1 To UBound(ar)
- If d.exists(ar(i, 1)) Then br(i, 1) = d(ar(i, 1)) Else br(i, 1) = 0
- If d.exists("A" & ar(i, 1)) Then br(i, 2) = d("A" & ar(i, 1)) Else br(i, 2) = 0
- If d.exists("B" & ar(i, 1)) Then br(i, 3) = d("B" & ar(i, 1)) Else br(i, 3) = 0
- br(i, 4) = d("C" & ar(i, 1))
- br(i, 5) = d("D" & ar(i, 1))
- ar(i, 1) = d("E" & ar(i, 1))
- Next
- [j6].Resize(i - 1, 5) = br
- If i > 1 Then [e6].Resize(i - 1) = ar Else [e6] = ar(1, 1)
- End Sub
复制代码 |
|