Excel Function: TEXTJOIN

Purpose

The TEXTJOIN function generates a text value by combining (1) values passed to it through one or many of its textn arguments and (2) sequences of characters which delimit the boundaries of those values. Values passed to any textn argument can take the form of a literal or be encapsulated by either a cell range or an array constant. TEXTJOIN moves sequentially through each textn argument, adds values to its output in the order they are encountered and separates values with delimiters. Cell ranges and array constants are read from top to bottom, and from left to right.

Invocations of the TEXTJOIN function take the form:

TEXTJOIN(delimiter,ignore_empty,text1,[text2],[text3] ... ,[text251])

Example

Consider a cell containing the formula:

=TEXTJOIN({"//","||","\\"},TRUE,A1:B2,"d",{"e","f","g"})

The text1, text2 and text3 arguments were passed the cell range A1:B2, the literal value “d” and an array constant containing the values “e”, “f” and “g” respectively. Because TEXTJOIN works sequentially through each textn argument, it first reads the values in the cell range A1:B2 and the values “a”, “b” and “c” are added to its output. Cell B2 is ignored since it is empty and the value passed to the ignore_empty argument is TRUE. Then, “d”, “e”, “f”, and “g” are added. TEXTJOIN separates values by placing delimiters between them. The 1st and 2nd values are separated by “//”, the 2nd and 3rd values by “||”, and the 3rd and 4th values by “\\”. This pattern is repeated as TEXTJOIN adds the 5th, 6th and 7th values to its output. The process is illustrated below:

The text1 argument is passed the cell range A1:B2. Cell A1 contains the value “a”, B1 contains “b”, A2 contains “c” and B2 is blank. The text2 argument is passed the literal value “d”, and text3 is passed an array constant containing the values “e”, “f” and “g”. Three delimiters were defined with the first being “//”, the second being “||” and the last being “\\”. Step 1: Add the values referred to by the text1 argument. The 1st cell is A1 and "a" is added to the output. The output is “a”. Step 2: Add the values referred to by the text1 argument. The 2nd cell is B1 and "b" is added to the output. "//" separates "a" from "b". The output is “a//b”. Step 3: Add the values referred to by the text1 argument. The 3rd cell is A2 and "c" is added to the output. "||" separates "b" from "c". The output is “a//b||c”. Step 4: Add the values referred to by the text1 argument. The 4th cell is B2 which is empty. Since ignore_empty = TRUE, the output is unchanged. Step 5: Add the value referred to by the text2 argument. "d" is added. "\\" separates "c" from "d". The output is “a//b||c\\d”. Step 6: Add the values referred to by the text3 argument. The 1st value is "e" and is added to the output. "//" separates "d" from "e". The output is “a//b||c\\d//e”. Step 7: Add the values referred to by the text3 argument. The 2nd value is "f" and is added to the output. "||" separates "e" from "f". The output is “a//b||c\\d//e||f”. Step 8: Add the values referred to by the text3 argument. The 3rd value is "g" and is added to the output. "\\" separates "f" from "g". The output is “a//b||c\\d//e||f\\g”.

Arguments

ArgumentArgument typeDescription
delimiterOptional. Defaults to “” if omitted.One or more sequences of characters placed between the values from which TEXTJOIN generates its output. More than one delimiter can be specified by passing them to the delimiter argument through either a cell range or an array constant. If more than one delimiter is specified then they will be cycled into TEXTJOIN’s output. For example if “;“, “|” and “%” were defined as delimiters in that order then they will appear in TEXTJOIN’s output in the order “;” → “|” → “%” → “;” → “|” …
ignore_emptyOptional. Defaults to TRUE if omitted.The ignore_empty argument determines how TEXTJOIN manages situations in which elements of a cell range or array constant passed to one of TEXTJOIN’s textn arguments are empty. It can assume one of two values:
ValueDescription
TRUETEXTJOIN provides no indication in its output that it was in receipt of an empty value. For example, if the delimiter were defined as “|“, the array constant {“a”,”b”,””,”d”} were provided to the text1 argument and ignore_empty were TRUE, the result would be “a|b|d“.
FALSETEXTJOIN adds two delimiters with nothing between them to indicate it was in receipt of an empty value. For example, if the delimiter were defined as “|“, the array constant {“a”,”b”,””,”d”} were provided to the text1 argument and ignore_empty were FALSE, the result would be “a|b||d“.
text1Optional. Defaults to “” if omitted.A value or a set of values added to TEXTJOIN’s output. The text1 argument can be passed either a literal value, a cell range or an array constant. The latter two facilitate the provision of more than one value via the text1 argument.
text2 … text251Optional251 arguments each capable of receiving one or many values that will be included in the output produced by TEXTJOIN. Each argument can be passed either a literal value, a cell range or an array constant. The latter two facilitate the provision of more than one value to TEXTJOIN via a single argument.

Related Functions

FunctionExamplePurpose
CONCATCONCAT(text1, text2)Its purpose is identical to that of the TEXTJOIN function: the CONCAT function joins values together and produces one text value as output. CONCAT differs from TEXTJOIN in that:
  • It is incapable of placing delimiters between the values it joins together.
  • Its ability to handle missing values is less sophisticated than TEXTJOIN’s.

Error Conditions

Error valueCondition typeCondition
#VALUE!RuntimeThe length of TEXTJOIN’s output exceeds 32,767 characters in length.

Examples

ExampleFormulaResultDescription
1=TEXTJOIN(,,)Invoke TEXTJOIN and omit all arguments.
  • No value was passed to the delimiter argument.
  • No value was passed to the ignore_empty argument.
  • No values were supplied through any textn argument.
  • The empty text value (“”) was returned.
2=TEXTJOIN("|",TRUE,{"a","b","","d"})a|b|dJoin multiple values, including the empty text value.
  • |” will delimit values.
  • The empty text value will be ignored.
  • The values “a”, “b”, “” and “d” will be joined together.
3=TEXTJOIN("|",TRUE,{"a","b","","d"})a|b||dJoin multiple values, including the empty text value.
  • |” will delimit values.
  • The empty text value will not be ignored.
  • The values “a”, “b”, “” and “d” will be joined together.
4=TEXTJOIN(
    {"|","?"},
    TRUE,
    {"a","b","","d"}
)
a|b?dJoin multiple values, including the empty text value.
  • |” and “?” will delimit values.
  • The empty text value will be ignored.
  • The values “a”, “b”, “” and “d” will be joined together.
5=TEXTJOIN(
    {"|","?"},
    FALSE,
    {"a","b","","d"}
)
a|b?|dJoin multiple values, including the empty text value.
  • |” and “?” will delimit values.
  • The empty text value will not be ignored.
  • The values “a”, “b”, “” and “d” will be joined together.

Examples: Errors

ExampleFormulaResultDescription
1=TEXTJOIN(,,REPT("a",32768))#VALUE!Generate a value > 32767 characters in length.
  • The TEXTJOIN function is limited to generating values ≤ 32,767 characters in length.
  • Because this limit would be exceeded, #VALUE! is returned.