One of the key skills you need to be good with Excel formulas is concatenation. Put simply, concatenation is just a fancy name for joining text together. In Excel formulas, the primary operator for concatenation is the ampersand (&). A good example of a simple concatenation task is the creation of an email address using a first and last name. There are many ways to create an email address, but the core problem is to join together a name and a domain, as seen in the worksheet shown. The formula in E5, copied down, is:
- How to concatenate in Excel - article
- LEFT function - overview
- LOWER function - overview
- How to change case with UPPER, LOWER, and PROPER - video
How the formula works
In the example shown, the formula in E5 is:
Working from the inside out, the LEFT function is used to get the first character of the first name like this:
LEFT(C5) // returns "T"
LEFT extracts text from the left side of a text string. Normally, we would also give LEFT the number of characters to extract as num_chars argument. However, in this case, we only want the first character and it turns out that num_chars defaults to 1, so there is no need to provide a number. With "Tom" in cell C5, the LEFT function returns "T". We then use the concatenation operator (&) to combine the result from LEFT with cell B5:
=LEFT(C5)&B5 ="T"&"BROWN" ="TBROWN"
The result is the text string "TBROWN", which is returned directly to the LOWER function. Simplifying, at this point we have the following:
The LOWER function converts any uppercase characters in a text string to lowercase characters. In this case, LEFT converts "TBROWN" to "tbrown":
=LOWER("TBROWN") // returns "tbrown"
Simplifying again, we now have:
The remaining formula concatenates the text "tbrown" to the "@" character, and the result is then concatenated to cell E2, as shown below:
="tbrown@"&$E$2 ="tbrown@"&"abc.com" ="email@example.com"
With "abc.com" in cell E2, the final result is "firstname.lastname@example.org". Notice that the reference to cell $E$2 is an absolute reference to prevent this cell from changing as the formula is copied down the column.
Alternate email address schemes
In a work environment, there are many different schemes for creating an email address. For example, a name like "Tom Brown" may appear as email@example.com, firstname.lastname@example.org, email@example.com, firstname.lastname@example.org, etc. The attached worksheet contains formulas for these alternatives:
=LOWER(LEFT(C5)&B5)&"@"&$E$2 // email@example.com =LOWER(C5&"."&B5)&"@"&$E$2 // firstname.lastname@example.org =LOWER(B5&"_"&C5)&"@"&$E$2 // email@example.com =LOWER(C5&B5)&"@"&$E$2 // firstname.lastname@example.org
Notice all variations use concatenation in different ways to create a different email address. They also use the LOWER function to force all parts of the name to lowercase characters only.
If you prefer, you can also use the CONCAT function to solve this problem like this:
CONCAT joins all four values with concatenation without the need for the & operator. The result from CONCAT, "TBROWN@abc.com", is returned directly to the LOWER function:
=LOWER("TBROWN@abc.com") // returns "email@example.com"
The final result is "firstname.lastname@example.org" as in the original formula above. Note that in this formula, we run the entire text string through the LOWER function to keep things simple.
Note: In an old version of Excel without CONCAT, you can use the CONCATENATE function with the same result.