View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jim Cone Jim Cone is offline
external usenet poster
 
Posts: 3,290
Default Concatenation

And one more way...
'-------------------------------------------------------
'Loads an array with the text values from the selection.
'Uses the Join function to concatenate the array elements.
'Assigns the joined values to the A1 cell.
'Note: the Join function is available only in recent versions of XL.
'Jim Cone - 10/30/2004

Sub PutItTogether()
Dim rngSelect As Range
Dim rngCell As Range
Dim N As Long
Dim lngCount As Long
Dim arrText() As String

If TypeName(Selection) = "Range" Then
Set rngSelect = Selection
lngCount = WorksheetFunction.CountA(rngSelect)

If lngCount 0 Then
ReDim arrText(1 To lngCount)
For Each rngCell In rngSelect
If Len(rngCell.Text) Then
N = N + 1
arrText(N) = rngCell.Text
End If
Next 'N
Range("A1").Value = Join(arrText)
End If
End If

End Sub
'-------------------------------------------------------
Jim Cone
San Francisco, CA


"Tony" wrote in message ...
Is there a way to concatenate contiguous text cells without using multiple
*&*s
For numeric values I can do *=SUM(A1.H1)* , but how do I create a text
string using all the characters of text in A1.H1?
TIA
Tony