How can I use the TEXTJOIN function with an IF statement in Excel?

The TEXTJOIN function in Excel allows users to combine multiple values into a single cell by specifying a delimiter. By using an IF statement in conjunction with the TEXTJOIN function, users can also add a logical condition to the formula, which will only join the values if the condition is met. This can be useful in situations where certain values need to be excluded or included based on a specific criteria. By combining these two functions, users can efficiently manipulate and organize their data in an Excel worksheet.

Excel: Use TEXTJOIN IF Formula


You can use the TEXTJOIN function in Excel to combine multiple text values using a specific delimiter.

If you only want to combine cells based on criteria, you can use the TEXTJOIN function with the IF function as follows:

=TEXTJOIN(", ",TRUE,IF(B2:B11="Western",A2:A11,""))

This particular formula combines the text values in the range A2:A11 only if the corresponding cell in the range B2:B11 is equal to “Western.”

The following example shows how to use this formula in practice.

Example: How to Use TEXTJOIN IF in Excel

Suppose we have the following dataset in Excel that contains information about various professional basketball teams:

Suppose we would like to combine each of the team names into one cell, only if the team belongs to the Western conference.

We can type the following formula into cell D2 to do so:

=TEXTJOIN(", ",TRUE,IF(B2:B11="Western",A2:A11,""))

The following screenshot shows how to use this formula in practice:

Excel TEXTJOIN IF

Cell D2 has joined together each of the team names that belong to the Western conference, with a comma used as a delimiter.

If we view the original dataset, we can confirm that each of the teams included in cell D2 do indeed belong to the Western conference:

Note #1: To use a different delimiter to join together the text values, simply specify that delimiter in the first argument of the TEXTJOIN function.

Additional Resources

The following tutorials explain how to perform other common operations in Excel:

x