|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
本帖最后由 lrh788 于 2018-3-27 12:47 编辑
Set d = CreateObject("Scripting.Dictionary")
ar = Sheets("订单").Cells(1, 1).CurrentRegion
For i = 2 To UBound(ar)
ar(i, 1) = ar(i, 1) & ar(i, 2) & ar(i, 3) & ar(i, 4)
For j = 5 To UBound(ar, 2)
d(ar(i, 1) & ar(1, j)) = d(ar(i, 1) & ar(1, j)) & ar(i, j)
Next j
Next i
br = Cells(1, 1).CurrentRegion
ReDim br1(1 To UBound(br), 1 To 1)
For i = 2 To UBound(br)
br1(i, 1) = br(i, 1) & br(i, 2) & br(i, 3) & br(i, 4)
For j = 5 To UBound(br, 2)
br(i, j) = d(br1(i, 1) & br(1, j))
Cells(i, j) = br(i, j)
Next j
Next i
End Sub
运行此代码在数据量几万时还行,但超过10万就慢了,等到最后还时常报错!能否优化代码?减少循环语句?请大师完善下,急用!!! |
|