|
本帖最后由 xiangbaoan 于 2018-9-9 12:55 编辑
一次性说明要求该多好,数量对应AJ列数据,那么单位、单价、金额分别对应哪些列的数据呢?
还有,没花提不起神……
此为补充代码:
Sub test()
Dim a, d As Object, tp, ar(), br, r&, y&, c%, s$
Set d = CreateObject("scripting.dictionary")
a = Array(9, 5, 4, 8) '这几个数中,9对应AJ列,其余的5、4、8均为猜测,你得自行调整并对应。
With ActiveSheet
br = .Range("ab4:aj" & .[ab65536].End(xlUp).Row)
For r = 1 To UBound(br)
s = br(r, 1) & br(r, 2)
If Len(s) Then d(s) = r
Next
tp = .Range("b4:c" & .[b65536].End(xlUp).Row)
ReDim ar(1 To UBound(tp), 1 To 4)
For r = 1 To UBound(tp)
s = tp(r, 1) & tp(r, 2)
If d.exists(s) Then
y = d(s)
For c = 1 To 4
ar(r, c) = br(y, a(c - 1))
Next
End If
Next
.[i4].Resize(UBound(ar), 4) = ar
End With
Set d = Nothing
End Sub
|
评分
-
1
查看全部评分
-
|