I see no reason to use Dictionary....
Select Column(s) that you want to concatenate.
It will only concatenate when selected column has value.
Private Sub CommandButton21_Click()
Dim rng As Range, r As Range, i As Long
On Error Resume Next
Set rng = Application.InputBox("Select column(s)", Type:=8)
On Error GoTo 0
If rng Is Nothing Then Exit Sub
With Cells(1).CurrentRegion
ReDim a(1 To .Rows.Count, 1 To 2)
a(1, 1) = .Cells(1, 1).Value
a(1, 2) = "Concat"
For i = 2 To .Rows.Count
a(i, 1) = .Cells(i, 1).Value
For Each r In rng
If .Cells(i, r.Column) <> "" Then
a(i, 2) = a(i, 2) & IIf(a(i, 2) = "", "", "|") & _
.Cells(i, r.Column).Value
End If
Next
Next
With .Offset(, .Columns.Count + 1).Resize(, 2)
.CurrentRegion.ClearContents
.Value = a
End With
End With
End Sub
Bookmarks