Here is one I put together with some help from Bob Phillips:
'---------------------------------------------------------------------------------------
' Procedure : Concat
' DateTime : 12/22/2006
' Author : Bob Phillips <
[email protected]>
' Courtesy of microsoft.public.excel.programming newsgroup
' Co-Author : Mark Ivey <
[email protected]>
' Purpose : To help automate the function of concatenating cell
information
'---------------------------------------------------------------------------------------
'
Sub Concat()
Dim srcrng As Range
Dim tgtrng As Range
Dim oRow As Range
Dim cell As Range
Dim tmp As String
Dim delim As String
On Error GoTo ExitSub:
Set srcrng = Application.InputBox( _
"Select input range with mouse", Type:=8)
Set tgtrng = Application.InputBox( _
"Select target column with mouse", Type:=8)
delim = Application.InputBox("Input delimiting character" & vbCr & vbCr
& _
"Examples: ~ - . * or anything else you prefer" & vbCr & vbCr & _
"If this field is left blank, a space will be used", Type:=2)
If delim = "" Then delim = " " Else
If Len(delim) > 1 Then delim = Left(delim, 1) Else
If Not srcrng Is Nothing Then
For Each oRow In srcrng.Rows
tmp = ""
For Each cell In oRow.Cells
If Not cell.Value = "" Then tmp = tmp & cell.Value & delim
Next cell
If tmp <> "" Then
Cells(oRow.Row, tgtrng.Column).Value = _
Left(tmp, Len(tmp) - 1)
End If
Next oRow
End If
ExitSub:
Exit Sub
End Sub