I have little doubt this could be streamlined but I need to get on with some other bits & pieces so in the meantime... 
Function CONCATSTR(rngVals As Range, strDelim As String, Optional boolCap As Boolean)
Dim vData, lngCols As Long, lngCol As Long, strTemp As String
lngCols = rngVals.Columns.Count
If Application.CountA(rngVals) = 0 Then CONCATSTR = "Empty": Exit Function
If rngVals.Rows.Count > 1 Then
If lngCols = 1 Then
With rngVals
vData = Application.Transpose(Evaluate("IF(" & .Address & "<>"""",SUBSTITUTE(" & .Address & ","" "",""^""),REPT(" & .Address & ",1))"))
End With
Else
For lngCol = 1 To lngCols Step 1
If Application.CountA(rngVals.Columns(lngCol)) Then
With rngVals.Columns(lngCol)
vData = Application.Transpose(Evaluate("IF(" & .Address & "<>"""",SUBSTITUTE(" & .Address & ","" "",""^""),REPT(" & .Address & ",1))"))
End With
If lngCol < lngCols Then
CONCATSTR = CONCATSTR & Replace(Replace(Application.WorksheetFunction.Trim(Join(vData, " ")) & " ", " ", strDelim), "^", " ")
End If
End If
Next lngCol
End If
Else
With rngVals
vData = Evaluate("IF(" & .Address & "<>"""",SUBSTITUTE(" & .Address & ","" "",""^""),REPT(" & .Address & ",1))")
End With
End If
CONCATSTR = CONCATSTR & Replace(Replace(Application.WorksheetFunction.Trim(Join(vData, " ")), " ", strDelim), "^", " ")
If boolCap Then CONCATSTR = strDelim & CONCATSTR & strDelim
End Function
this should work for both vectors & matrices regardless of blanks etc... for everything except strings that contain valid ^
regards ^: it would pretty straightforward to create a constant array of "unusual chars" and iterate the array until such time as you find a char not present in the range of values being processed and subsequently code that into the replace function.
Bookmarks