The line:
Concat = Concat & r & myDelimiter
is calling the function recursively (with no arguments!). VBA allows
this type of statement, but I think it is generally better programming
practice to declare a local variable to use to concantenate the strings
together, then assign to the function at the end of the routine, like
so:
Function Concat(myRange As Range, Optional myDelimiter As String)
Dim strTemp As String
Dim r As Range
strTemp = ""
For Each r In myRange
strTemp = strTemp & r & myDelimiter
Next r
If Len(myDelimiter) > 0 Then
Concat = Left(strTemp, Len(strTemp) - Len(myDelimiter))
End If
End Function
--
Regards,
Bill Renaud
|