返回列表 上一主題 發帖

同一發票號碼列出所有訂單編號(列在同一儲存格)

多欄式:
Sub test_02()
Dim Arr, Brr, xD, i&, T$, T2$, R&, C%, Cx%, N&
Set xD = CreateObject("Scripting.Dictionary")
Arr = Range([a1], [b65536].End(3))
ReDim Brr(1 To UBound(Arr), 1 To 200)
For i = 2 To UBound(Arr)
    T = Arr(i, 1): T2 = Arr(i, 2)
    If T = "" Or T2 = "" Then GoTo 99
    R = xD(T):  C = xD(T & "/c")
    If R = 0 Then N = N + 1: R = N + 1: xD(T) = R: Brr(R, 1) = Arr(i, 1)
    C = C + 1: xD(T & "/c") = C: Brr(R, C + 1) = T2
    If C > Cx Then Cx = C: Brr(1, Cx + 1) = "訂單(" & Cx & ")"
99: Next i
Brr(1, 1) = "發票號碼"
Range("g1").Resize(N + 1, Cx + 1) = Brr
End Sub

TOP

        靜思自在 : 做好事不能少我一人,做壞事不能多我一人。
返回列表 上一主題