|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub Macro1() '1个字典
- Dim ar, br(), i&, j&, cr, dr, er, tt
- tt = Timer
- Dim d As Object
- Set d = CreateObject("Scripting.Dictionary")
- ' ar = Range([b6], [b6].End(4))
- ar = Range([b1], [b65536].End(3))
- 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 = 6 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 j = 6 To UBound(ar)
- i = j - 5
- 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
- Range("E6:E65536,J6:j65536").ClearContents
- [j6].Resize(i, 5) = br
- If i > 1 Then [e6].Resize(i - 1) = ar Else [e6] = ar(1, 1)
- MsgBox Timer - tt
- End Sub
复制代码 |
|