Pivot Table String Comma Delimited
I have a Source of data and I need t开发者_运维百科o show them in a summerized table.
Please see Output Sheet from atached file and let me know how can I make that
Please find the sample attachment
One way would be to have a user defined function to make the comma separated list
Function MergeCOO(rId As Range, r1 As Range, r2 As Range) As String
Dim vIdx As Variant
Dim vCOO As Variant
Dim Id As Variant
Dim i As Long, str As String
Dim c As New Collection
Id = rId.Value
vIdx = r1
vCOO = r2
On Error Resume Next
For i = LBound(vIdx, 1) To UBound(vIdx, 1)
If vIdx(i, 1) = Id Then
c.Add vCOO(i, 1), vCOO(i, 1)
If Err.Number <> 0 Then Err.Clear
End If
Next
For i = 0 To c.Count
str = str & c.Item(i) & ","
Next
MergeCOO = Left(str, Len(str) - 1)
End Function
Add a formula to column L
in sheet Source
=MergeCOO([@[HS Code]],[HS Code],[COO])
Then you can add this extra column to your report as you see fit
精彩评论