how to concatenate more than 40 lines in vba how to concatenate more than 40 lines in vba

The solution for “how to concatenate more than 40 lines in vba how to concatenate more than 40 lines in vba” can be found here. The following code will assist you in solving the problem.

Function ConcatenateRange(ByVal cell_range As range, _
Optional ByVal seperator As String) As String

Dim newString As String
Dim cellArray As Variant
Dim i As Long, j As Long

cellArray = cell_range.Value

For i = 1 To UBound(cellArray, 1)
For j = 1 To UBound(cellArray, 2)
If Len(cellArray(i, j)) <> 0 Then
newString = newString & (seperator & cellArray(i, j))
End If
Next
Next

If Len(newString) <> 0 Then
newString = Right$(newString, (Len(newString) – Len(seperator)))
End If

ConcatenateRange = newString

End FunctionFunction ConcatMe(Rng As Range) As String

Dim cl As Range

ConcatMe = “”

For Each cl In Rng
ConcatMe = ConcatMe & cl.Text
Next cl

End Function

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

Similar Posts