UDF - TEXTJOIN ( delimeter , ignore_blanks , "value"/range, ["value"/range] ..)

Here is a UDF version of the TEXTJOIN function from Excel 2016 365.. for use in earlier Excel versions.

Copy the code into a worksheet module and it will be available for use..

TEXTJOIN( delimiter , ignore_empty , "value"/range, ["value"/range]..)

=TEXTJOIN(",",TRUE,A1:D1)

Column1Column2Column3
redyellowblue
orangebrown
Formula
=TEXTJOIN(" : ",TRUE,"Jon","Peter","Bill",B1:C3,123,456,789)
Result
Jon : Peter : Bill : Column1 : Column2 : Column3 : red : yellow : blue : orange : brown : 123 : 456 : 789

Paste the following code into a worksheet module for it to be available for use.


Function TEXTJOIN(delim As String, ie As Boolean, ParamArray arguments() As Variant) As Variant
'Reddit.com/u/excelevator
'See Microsoft TEXTJOIN Helpfile
Dim tmpStr As String 'build cell contents for conversion to array
Dim uB As Long
Dim arg As Long
uB = UBound(arguments)
For arg = 0 To uB
    If TypeName(arguments(arg)) <> "Range" Then
       tmpStr = tmpStr + CStr(arguments(arg)) + delim
    Else
        For Each cell In arguments(arg)
            If ie = True And cell = "" Then
                'do nothing 
            Else
                tmpStr = tmpStr + CStr(cell) + delim
            End If
        Next
    End If
Next
TEXTJOIN = Left(tmpStr, Len(tmpStr) - Len(delim))
End Function

Posted Jan 8, 2017, 3:47 AM UTC · edited

10

No comments yet

Nobody commented on this post, or the comments weren't captured.