ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Concatenation (https://www.excelbanter.com/excel-programming/315298-re-concatenation.html)

Jim Cone

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




All times are GMT +1. The time now is 11:25 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com