7 Ways to Use TEXTJOIN in Microsoft Excel

Today, I’ll help you learn how to use TEXTJOIN in Microsoft Excel. Keep reading!

You need to use the TEXTJOIN function in Excel to merge text strings with a delimiter, like a comma, semicolon, etc. This function allows you to merge first names and last names in full names, user names, and email domains into complete email addresses, generate comma-separated lists of values, and so on.

In this Excel TEXTJOIN tutorial, I have presented and discussed a few real-time situations where you can utilize this function to save time and effort. Let’s get started!

Basic Text Concatenation With a Delimiter

Before you can start using the TETXJOIN function, let me introduce you to its formula syntax and explanation of the arguments:

  • delimiter: The character(s) to insert between text values, like a comma, semicolon, dash, and so on.
  • ignore_empty: TRUE ignores empty cells, while FALSE includes them.
  • text1, text2, …: The text values, cell references, or ranges to be joined.

A limitation of this function is that it doesn’t allow joining different text strings using separate types of delimiters. You can join two or more text strings using only one type of delimiter.

Sample dataset 1

Now, suppose you’ve got a dataset shown in the above screenshot. It lists first names, last names, and email domains in different columns. Now, you’d like to create a complete email address using these data. Your dataset doesn’t have to be exactly as shown in the above example, but it could be similar.

Creating the basic TEXTJOIN function
Creating the basic TEXTJOIN function

Here, you can easily use the TEXTJOIN function to join the first and last names using a delimiter like a period. Then, you can join the full name with the email domain with the @ symbol using the standard concatenation symbol, which is the ampersand (&).

So, let me show you the quick steps you can practice on your end:

Select the destination cell where you want to combine the text strings.

Enter the following formula syntax into the selected cell:

=TEXTJOIN(".",TRUE,A2,B2)&"@"&C2

All the cell references are the text strings that are being joined by this formula. These are dynamic, so you can use the fill handle for the rest of the cells.

Ensure you edit the cell references according to your own dataset.

Calculating TEXTJOIN
Calculating TEXTJOIN

Now, hit Enter to calculate the first cell.

Select this cell and drag it down the column to apply the formula to the rest of the cells in the same column.

Joined text strings using TEXTJOIN
Joined text strings using TEXTJOIN

That’s it! You’ve successfully used the basic TEXTJOIN function to join text strings.

Ignoring Blank Cells

The TEXTJOIN function comes with an argument to include or exclude empty cells. If you don’t use this argument appropriately, the function will show the delimiter at the end of the first text string. This won’t look professional in your reports.

So, you need to enable the ignore empty cells feature in this function to not to use the delimiter at the end of the first text string when there’s no other text string in the second cell.

Let me explain the problem below with an example:

TEXTJOIN with empty cell detction disabled
TEXTJOIN with empty cell detection disabled

Suppose you’re using the following TEXTJOIN formula syntax to merge first and last names:

=TEXTJOIN(".",FALSE,A2,B2) 

However, the Last Name column doesn’t have any text strings in it.

The result would look like the example shown below:

John.

The period at the end of the first name doesn’t look professional.

TEXTJOIN with empty cell detction enabled
TEXTJOIN with empty cell detection enabled

Instead, you can use the following formula to merge cell contents:

=TEXTJOIN(".",TRUE,A2,B2)

Since the empty cell detection is set to TRUE, Excel won’t show the delimiter, the period, at the end of the first text, even if the second text isn’t available.

Merging Data From Multiple Columns

Suppose you want to merge multiple text strings from more than two columns. You can speed up the process by simply refercning the starting and ending columns joined with a colon.

For example, if you need to join text strings from columns A, B, and C, simply use A2:C2 as the cell range reference in the first cell, considering A1, B1, and C1 contains column headers. This will automatically merge all the text strings in columns A, B, and C.

Let me show you the steps with an example below:

Sample dataset 2

The dataset I’m using is the one shown above. There are text strings in three columns that I wish to join. These column headers are First Name, Middle Name, and Last Name. After joining the text strings, I want to generate the result in the Full Name column.

TEXTJOIN with multiple columns
TEXTJOIN with multiple columns

So, I entered the following formula syntax in D2:

=TEXTJOIN(" ",TRUE,A2:C2)

When you use this formula syntax, don’t forget to modify the cell range reference.

Calculating TEXTJOIN with multiple columns
Calculating TEXTJOIN with multiple columns

After pressing the Enter key, I get the merged text string in D2.

Then, I used the fill handle D2 and dragged it down to apply the same formula to the rest of the cells.

Used TEXTJOIN for multiple columns
Used TEXTJOIN for multiple columns

Excel generated the merged text in the Full Name column.

Adding a Prefix or Suffix

If you need to add a prefix or suffix to merged text strings, you can do that using the TEXTJOIN function. Let me show you how in easy steps:

Suppose you’ve got a dataset of octets of IP addresses in First Octet, Second Octet, Third Octet, and Fourth Octet. You wish to combine the values from these columns into an IP address and put the suffix IP: at the beginning of the concatenated values.

Sample dataset 3

You can find above the structure of the dataset. You can start this process of joining text strings or numbers.

Create a column named IP Address and select the first cell below this column header.

Using TEXTJOIN to add a prefix
Using TEXTJOIN to add a prefix

Enter the following formula into this cell:

=TEXTJOIN(". ", TRUE, "IP: "&A2,B2,C2,D2)

In the above formula, "IP: " is linked to A2 using the ampersand (&) symbol, which is the built-in concatenation function in Excel. This code will add the IP: prefix to the complete IP address. Depending on the dataset you’re working on, you need to change the cell references.

Using fill handle for TEXTJOIN with prefix
Using fill handle for TEXTJOIN with prefix

Once done editing the formula, press Enter to calculate the cell. Use the fill handle and drag it down the column to apply the same formula to the rest of the cells in the IP Address column.

Addedd a prefix in merged text strings using TEXTJOIN
Added a prefix in merged text strings using TEXTJOIN

Excel will merge the values in the referred columns and add the prefix at the beginning of the final value or text string.

Concatenate With Line Breaks

Suppose you’ve got a list of customer addresses stored across multiple cells. You want to merge them into a single cell and properly format the address with line breaks. Here, you can use this modification of the TEXTJOIN function.

Instead of a text-based delimiter, you’ll use the line break code, CHAR(10), and the rest of the formula syntax will remain the same. The split texts in multiple columns will be concatenated and formatted with the linebreak code.

Sample dataset 4

The above screenshot tells you about the structure of the sample dataset.

Wrap Text
Wrap Text

Select a destination cell where you wish to get the output. Click on the Wrap Text command in the Alignment block of the Home tab.

Now, enter the following formula into the selected cell:

=TEXTJOIN(CHAR(10),TRUE,A2:E2) 

Change the cell range reference in the above formula so that it can fetch data from your worksheet appropriately.

Hit Enter to calculate the cell.

Calculating TEXTJOIN with CHAR
Calculating TEXTJOIN with CHAR

You’ll see that Excel has merged the split texts into a line-break formatted address.

Comma-Separated List With Unique Values

Often, you need to create a list of comma-separated items from a vertical column containing data on products, merchandise, etc. In this situation, you can use TEXTJOIN with the UNQIUE function to concatenate only the unique values from the column or vertical list.

Sample dataset 5

For example, your starting dataset could look like the one shown above.

Using TEXTJOIN with UNIQUE
Using TEXTJOIN with UNIQUE

Now, select any cell from a column where you wish to produce this concatenated list of unique values.

Copy and paste the following formula into the cell:

=TEXTJOIN(",",TRUE,UNIQUE(A2:A6)) 

Before using the formula as is, make sure that you’ve changed the cell range reference in the formula syntax.

Calculated TEXTJOIN and UNIQUE
Calculated TEXTJOIN and UNIQUE

Now, hit Enter to get the merged comma-separated list of items.

This is an alternative way of transposing a dataset in Excel.

Create a Dynamic Sentence

If you often need to generate product descriptions from an ever-changing list of products, you can use this method to automate the task. Here, I’ll show you how the TEXTJOIN function can help you dynamically change the product details in a pre-composed product details text.

Most of the sentence structure remains the same except for the product name and its features. Let me show you how below:

Sample dataset 6

Suppose you’ve got a dataset that looks like the one shown above.

TEXTJOIN for dynamic sentence
TEXTJOIN for dynamic sentence

Select a cell where you’d like to create the dynamic sentence and enter the following formula into it:

=TEXTJOIN(" ", TRUE,
    "This", A2,
    "comes in", LOWER(B2),
    "and size", C2,
    "for just", D2, "."
)

Make sure you change the cell range references according to your source dataset. Also, you can change the text strings or words within the double-quoted fields in the formula syntax.

Created a dynamic sentence
Created a dynamic sentence

Once done configuring the formula, press Enter to calculate the cell.

Excel will merge the product details with fixed text strings to compose the dynamic sentence.

Changing product name
Changing product name

Now, the next time, you only need to change the details in the product features table. The sentence will be created automatically for the new product.

📚 Read more: You might also find these Excel tutorials relevant:

Conclusions

Now you know how to use TEXTJOIN in Excel in basic to advanced ways. Hopefully, this Excel TEXTJOIN function tutorial will help you automate various tasks in an Excel worksheet where the ultimate goal is to merge text strings or numerical values.

If the guide helped you learn a new Excel skill, use the comment box to share your acknowledgment. You can also mention any suggestions.

About the Author

Bipasha Nath

Bipasha Nath

Bipasha is a technical content writer with 10+ years of experience in the technology industry. She previously worked in a SaaS software development company focused on SharePoint, OneDrive, Word, Excel, Word solutions.

Related Posts

Comments

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Get the Latest Microsoft Excel Tips

Follow Us

Follow us to stay up to date with the latest in Microsoft Excel!

Subscribe for awesome Microsoft Excel videos 😃