Sub A新DP判斷_2()
Dim Ar, Br, D, F1 As Range, F2 As Range, i&, N&, T$, U&, V
[J:K].ClearContents
Set F1 = [A:A].Find("D/P", Lookat:=xlWhole)(3, 1) '尋找"D/P"的位置, 並向下移3格(即資料的開頭)
Set F2 = [A:A].Find("CUP PRINT").End(xlUp)(1, 3) '尋找"CUP PRINT"的位置, 並向上取非空位置, 再向右移3格
Ar = Range(F1, F2)
ReDim Br(1 To UBound(Ar), 1 To 2)
Set D = CreateObject("Scripting.Dictionary")
For i = 1 To UBound(Ar)
T = Ar(i, 3): If T = "" Then GoTo 99 '若AMOUNT為空, 略過
U = D(T) '取得AMOUNT已存入字典檔的位置
If U = 0 Then N = N + 1: U = N: D(T) = N: Br(N, 1) = T '如果尚未存入字典檔, N+1遞增存入, 並將AMOUNT值放入Br陣列
Br(U, 2) = Replace(Trim(Br(U, 2) & " " & Ar(i, 2)), " ", "-") '依據U值的位置, 將B欄文字存入Br
99: Next i
If N > 0 Then Cells(F1.Row, "J").Resize(N, 2) = Br
End Sub