Confident CellsExcel practice Start free

Text: CONCAT, TEXTJOIN, TEXTBEFORE, TEXTAFTER: practice exercises

CONCAT, TEXTJOIN, TEXTBEFORE, TEXTAFTER. 6 exercises on real-looking data, each marked the moment you press Check. The first exercise is below to try now; the full lesson is part of Pro.

Your turn

In C2, use CONCAT to join each first name and surname, with a space between them.

ABC
1First nameSurnameFull name
2WillBaker
3JessSmith
4TomBrown
5RachelAhmed
6ChenAli
7GraceHall
8HannahHughes
9AlexPatel
10KerryTaylor
11BenBennett

How it works

CONCAT(a, b, c…) joins text in one go, like a&b&c. TEXTJOIN(separator, TRUE, range) joins a whole range with a separator between each one, and TRUE skips the empty cells.

TEXTBEFORE(text, "@") gives everything before the first @, and TEXTAFTER(text, "@") everything after it. Add -1 as a third argument to use the last one instead of the first.

=CONCAT(A2,".",B2) =TEXTJOIN(", ",TRUE,B3:E3) =TEXTBEFORE(C2,"@") =TEXTAFTER(A4," ",-1)

Joining text

You've joined text with &: =A2&" "&B2. Two functions do the same job:

  • CONCAT(A2," ",B2) joins everything you list, in order. It saves typing lots of & signs.
  • TEXTJOIN(", ",TRUE,B2:E2) joins a whole range, putting the separator between each item. TRUE means skip empty cells, so you don't get double commas.

Worked example: splitting

ABC
1FirstLastEmail
2AmiraShahamira.shah@company.co.uk
3BenLoweb.lowe@company.co.uk
4Cara Jane Wood
  1. =TEXTBEFORE(C2,"@") in D2. TEXTBEFORE takes everything before the first @: amira.shah.
  2. =TEXTAFTER(C2,"@") in D2. TEXTAFTER takes everything after it: company.co.uk.
  3. =TEXTAFTER(A4," ",-1) in D4. Cara has a middle name. A third argument of -1 means the last space, so you get only the surname, Wood.

One inside the other

To take out a middle part, such as 4821 from NTH-4821-B, put one inside the other: TEXTAFTER(A2,"-") gives 4821-B, and TEXTBEFORE of that, before the "-", gives 4821.

TEXTBEFORE and TEXTAFTER are in Excel 365 and Excel 2024, but not Google Sheets. In older Excel or in Sheets, use LEFT, MID and FIND.

What you'll practise

  1. In C2, use CONCAT to join each first name and surname, with a space between them.
  2. Staff IDs are the department code, a dash, then the number with 4 digits: department ABC and number 37 would make ABC-0037. In D2, use CONCAT and TEXT(C2,"0000") to build each ID.
  3. In F2, list each person's skills in one cell, separated by a comma and a space, with no extra commas for the empty boxes.
  4. Each person's username is the part of their email before the @. In C2, use TEXTBEFORE to take it out.
  5. Some people gave a middle name too. In B2, take out each surname: everything after the last space.
  6. Order codes look like NTH-4821-B, but each part can be a different length. In B2, take out the middle part, between the two dashes.

Guides with worked examples: Split first and last names in Excel · TEXTSPLIT: splitting text into cells with a formula · Combine first and last names in Excel: &, CONCAT and TEXTJOIN · LEFT, MID and RIGHT: taking part of a code or a postcode