Combine text with different delimiters

Today, we are going to com­bine text with two, dif­fer­ent delim­iters. In our exam­ple, we have shop and street names. We want to put a semi­colon between each shop and street name. How­ev­er, between street and shop names we want to put anoth­er sym­bol, which is a pipe. What is impor­tant in our exam­ple, is the fact that not all cells are filled. We want to just ignore them while com­bin­ing text (Fig. 1).

Com­bine text with dif­fer­ent delimiters
Fig. 1 — Text to combine

This task is very sim­ple in Excel 2019 and new­er ver­sions because we have the TEXTJOIN func­tion. In the first argu­ment of this func­tion, we are putting the delim­iter. We can even put more than one delim­iter. In our exam­ple, the delim­iters are placed in cells D9 and E9, so let’s put them in the for­mu­la and let’s lock them by press­ing the F4 key. When we put more than one delim­iter in the TEXTJOIN func­tion, the func­tion will use them alter­na­tive­ly, which means that first, it will use the semi­colon, then the pipe, then the semi­colon and so on. In next argu­ment we have to decide whether we want to ignore emp­ty cells or not. In this case, as I said ear­li­er, it’s very impor­tant for us to ignore them, so we are writ­ing TRUE or 1. The last argu­ment we need is just text, i.e. the range with text. Let’s close the for­mu­la (Fig. 2)

=TEXTJOIN($D$9:$E$9,1,B2:G2)

Fig. 2 — For­mu­la for com­bin­ing text

After putting it into the cell, let’s copy it down. We have the results. We can see there are semi­colons between shop and street names, and pipes between street and shop names (Fig. 3).

Fig. 3 — Com­bined text

In the TEXTJOIN for­mu­la, delim­iters ori­en­ta­tion is not impor­tant. They can be hor­i­zon­tal or vertical.

We can even hard­code them here by select­ing first argu­ment and press­ing the F9 key to eval­u­ate it. Now, they are writ­ten as text (Fig. 4).

=TEXTJOIN({“;”,”|”},1,B2:G2)

Fig. 4 — Hard­code delimiters

We can leave them like that and the for­mu­la will work the same. 

https://www.youtube.com/watch?v=Euhk_dOil4Q

Extract middle names with Flash Fill

Today, we are going to extract mid­dle names from full names. How­ev­er, not every­body has got a mid­dle name, so let’s start with the first and the last name. We can use here the Flash Fill option, which means that we just have to start writ­ing the first name, then anoth­er first name. After that, the Flash Fill com­mand does the work for us (Fig. 1).

Extract mid­dle names with Flash Fill
Using the Flash Fill option
Fig. 1 — Using the Flash Fill option

All we need to do is accept the results with Enter, and we have the first names (Fig. 2)

Entering the results
Fig. 2 — Enter­ing the results

We do the same with the last name, i.e., we start writ­ing the last name in the first cell, but this time we will force the Flash Fill option to work by press­ing the Ctrl + E key­board short­cut (Fig. 3).  This way, we have last names (Fig. 4)

 Flash Fill
Fig. 3 — Flash Fill
Flash Fill results
Fig. 4 — Flash Fill results

Now, the hard­est part – mid­dle names. We start writ­ing the mid­dle name in the first row, how­ev­er, we don’t have a mid­dle name in the sec­ond row. This time we’ll also use the Flash Fill option (Fig. 5)

Flash Fill for middle names
Fig. 5 — Flash Fill for mid­dle names

When all mid­dle names have been extract­ed, we can see an error. Edward isn’t a mid­dle name. We have to cor­rect the Flash Fill answer. We can do it, until the Flash Fill Options icon is show­ing up (Fig. 6).

Flash Fill icon
Fig. 6 — Flash Fill icon

We have to change the mid­dle name, which, in fact, isn’t a mid­dle name, for a dif­fer­ent mark, e.g. an excla­ma­tion mark. We sim­ply write the mark in the place of the error, press Enter, and the Flash Fill option will do its mag­ic again (Fig. 7) Excla­ma­tion marks are in the rows, where there aren’t mid­dle names.

 Exclamation marks
Fig. 7 — Excla­ma­tion marks

We can put almost any­thing in the place of the excla­ma­tion mark, e.g. a star (Fig. 8).

Stars
Fig. 8 — Stars

We usu­al­ly don’t want any stars or oth­er signs. We want to have blank cells, how­ev­er, the Flash Fill option doesn’t work  with spaces. That’s why we can use the Fil­ter option, which we can find in the Data tab (Fig. 9). In the Fil­ter option, we want to show only this sign (a star).

Filter option
Fig. 9 — Fil­ter option

Now, we’re left only with stars (Fig. 10). We have to select the range (Ctrl + Shift + ↓) and press the Delete key to delete all the signs.

Selected range
Fig. 10 — Select­ed range

Then we can turn off the fil­ter. We can do it man­u­al­ly, by press­ing the fil­ter icon and select­ing the Clear Fil­ter From “Mid­dle names” option (Fig. 11) or by press­ing the Ctrl + Shift + L key combination.

Turning off the filter
Fig. 11 — Turn­ing off the filter

Now, we have mid­dle names only in places, where they real­ly exist, and blank cells, where there aren’t any mid­dle names (Fig. 12)

Extracted names
Fig. 12 — Extract­ed names

https://www.youtube.com/watch?v=v46vQGjwx0w