Someone helped me write the below code but now i need to change it so that the fields append with a ¬ or ? as a delimiter rather than a comma (,)
any ideas which character is telling it to delimite as a commas?
Sub ptest()
Dim a, b(), i As Long, n As Long
With Range("a2", Range("a" & Rows.Count).End(xlUp)).Resize(, 2)
a = .Value
ReDim b(1 To UBound(a, 1), 1 To 2)
With CreateObject("Scripting.Dictionary")
.CompareMode = vbTextCompare
For i = 1 To UBound(a, 1)
If Not IsEmpty(a(i, 1)) Then
If Not .exists(a(i, 1)) Then
n = n + 1
b(n, 1) = a(i, 1)
.Add a(i, 1), n
End If
' b(.Item(a(i, 1)), 2) = b(.Item(a(i, 1)), 2) & " " & a(i, 2)
b(.Item(a(i, 1)), 2) = b(.Item(a(i, 1)), 2) & IIf(b(.Item(a(i, 1)), 2) <> "", ", ", "") & a(i, 2)
End If
Next
End With
' .Value = b
End With
Sheets("Sheet1").Range("C1").Resize(n, 2).Value = b
End Sub
Bookmarks