Sometime ago, I received a VBA solution from some "EEEE"*
Concatenate in Excel without entering every cell reference
for the purpose of 1) concatenating the contents of multiple cells when the number of involved cells is too great to practically use the common concatenating Excel formula:
2) being able to select a custom delimiter.
The code in the solution is as follows:
Function strcat(rng As Range, Optional dlm As String = ",", Optional bUseFormat As Boolean = True)
Dim cel As Range
For Each cel In rng
If cel.Value <> "" Then strcat = strcat & dlm & IIf(bUseFormat, cel.Text, cel.Value)
strcat = Mid$(strcat, Len(dlm))
and the function to enter into the spreadsheet is here:
Something I noticed just recently that I had not noticed previously is that when using this code, a delimiter is inserted prior to the first cell's contents. For example, if the contents of five cells to be concatenated are:
respectively and the custom delimiter is a closing curly bracket "}", the result would be displayed as follows:
with the first character being a delimiter.
Could someone tweak the above code so that this initial delimiter is not included in the result display?
* EEEE = Excellent Experts-Exchange Experts