CONCAT Function in Excel

🌟 Part 1: Introduce

💡 Definition: The CONCAT function in Microsoft Excel combines multiple text strings into a single string. It allows you to concatenate or join the contents of different cells or text values, creating a new text string.

💡 Purpose: The purpose of the CONCAT function is to simplify the process of combining text from multiple sources into one cell. It is beneficial to merge names, addresses, or other pieces of information into a single cell or create custom messages or labels.

💡 Syntax & Arguments: The syntax of the CONCAT function is as follows:

syntax
CONCAT(text1, text2, ...)
  • text1, text2, ...: These are the text strings or cell references you want to concatenate. You can provide multiple arguments, separating them with commas.

💡 Return value: The CONCAT function returns a new text string that is the result of combining the provided text strings or cell values.

💡 Remarks:

  • The CONCAT function can concatenate text strings but does not automatically add spaces or other separators between the concatenated values. You must include any desired partitions as part of the text strings or use additional functions like CONCATENATE or TEXTJOIN to add walls.
  • Empty cells or cells with a blank value are treated as open text strings.
  • CONCAT can handle up to 253 arguments. If you exceed this limit, you may need to use CONCATENATE or TEXTJOIN instead.

🌟 Part 2: Examples

Let’s explore three examples that demonstrate the usage of the CONCAT function:

1️⃣ Example 1: Combining First Name and Last Name

ABC
1First NameLast NameFull Name
2JohnDoe=CONCAT(A2, ” “, B2)
3JaneSmith=CONCAT(A3, ” “, B3)
4BobJohnson=CONCAT(A4, ” “, B4)

In this example, we have a dataset with first names in column A and last names in column B, and we want to combine them to create the complete terms in column C.

  • The formula =CONCAT(A2, " ", B2) in cell C2 concatenates the first name in cell A2, a space, and the last name in cell B2, resulting in “John Doe.”
  • Similarly, the formula in cell C3 concatenates the first and last names in cells A3 and B3, resulting in “Jane Smith.”
  • The formula in cell C4 concatenates the first name and last name in cells A4 and B4, resulting in “Bob Johnson.”

2️⃣ Example 2: Creating Mailing Addresses

ABC
1Address Line 1Address Line 2Full Address
2123 Main StreetApt 4B=CONCAT(A2, “, “, B2)
3456 Oak Avenue=CONCAT(A3, B3)
4789 Pine DriveUnit 10=CONCAT(A4, “, “, B4)

In this example, we have a dataset with address details. We want to create the complete mailing addresses by combining address line 1 and address line 2, if available.

  • The formula =CONCAT(A2, ", ", B2) cell C2 concatenates the address line 1 in cell A2, a comma and space separator, and the address line 2 in cell B2, resulting in “123 Main Street, Apt 4B.”
  • The formula in cell C3 concatenates the address line 1 and address line 2 in cells A3 and B3, resulting in “456 Oak Avenue” (since address line 2 is empty).
  • The formula in cell C4 concatenates the address line 1 in cell A4, a comma and space separator, and the address line 2 in cell B4, resulting in “789 Pine Drive, Unit 10.”

3️⃣ Example 3: Creating Product Codes

AB
1Product NameProduct Code
2Widget A=CONCAT(“WA”, TEXT(ROW()-1, “000”))
3Widget B=CONCAT(“WB”, TEXT(ROW()-1, “000”))
4Widget C=CONCAT(“WC”, TEXT(ROW()-1, “000”))

In this example, we want to generate unique product codes based on the product names. The product codes consist of a prefix followed by a unique number.

  • The formula =CONCAT("WA", TEXT(ROW()-1, "000")) cell B2 combines the prefix “WA” with a unique number generated using the TEXT and ROW functions. The ROW function generates a sequential number based on the row position, and the TEXT function formats it as a three-digit number with leading zeros.
  • Similarly, the formula in cell B3 combines the prefix “WB” with a unique number.
  • The formula in cell B4 combines the prefix “WC” with a unique number.

 

4️⃣ Example 4: Creating Email Addresses

Assume you have a dataset with employee names and company email domains. You want to generate email addresses by combining employee names with domain names.

ABC
1Employee NameDomainEmail Address
2John Doeexample.com=CONCAT(LOWER(SUBSTITUTE(A2, ” “, “”)), “@”, B2)
3Jane Smithexample.com=CONCAT(LOWER(SUBSTITUTE(A3, ” “, “”)), “@”, B3)
4Bob Johnsonexample.com=CONCAT(LOWER(SUBSTITUTE(A4, ” “, “”)), “@”, B4)

In this example, the employee names are in column A, and the domain is in column B. We want to create email addresses by combining lowercase employee names with domain names.

  • The formula =CONCAT(LOWER(SUBSTITUTE(A2, " ", "")), "@", B2) in cell C2 converts the employee name in cell A2 to lowercase using the LOWER function, removes any spaces using the SUBSTITUTE function, and then concatenates it with the domain in cell B2, resulting in “[email protected].”
  • Similarly, the formula in cell C3 combines the modified employee name in cell A3 with the domain in cell B3.
  • The formula in cell C4 combines the modified employee name in cell A4 with the domain in cell B4.

5️⃣ Example 5: Generating Invoice Numbers

Assume you want to generate unique invoice numbers by combining a prefix with a sequential number.

AB
1PrefixInvoice Number
2INV=CONCAT(A2, TEXT(ROW()-1, “0000”))
3INV=CONCAT(A3, TEXT(ROW()-1, “0000”))
4INV=CONCAT(A4, TEXT(ROW()-1, “0000”))

In this example, the prefix for the invoice numbers is in cell A2. Using the TEXT and ROW functions, we want to generate unique invoice numbers by combining the prefix with a sequential number.

  • The formula =CONCAT(A2, TEXT(ROW()-1, "0000")) cell, B2 combines the prefix in cell A2 with a sequential number generated using the TEXT function and the ROW function. The ROW function generates a sequential number based on the row position, and the TEXT function formats it as a four-digit number with leading zeros.
  • Similarly, the formula in cell B3 combines the prefix in cell A3 with a sequential number.
  • The formula in cell B4 combines the prefix in cell A4 with a sequential number.

6️⃣ Example 6: Creating URL Links

Assume you have a dataset with product names and website domains. You want to create clickable URL links by combining the product names with the website domains.

ABC
1Product NameDomainURL Link
2Product Aexample.com=CONCAT(HYPERLINK(“https://”, B2, “/”, A2))
3Product Bexample.com=CONCAT(HYPERLINK(“https://”, B3, “/”, A3))
4Product Cexample.com=CONCAT(HYPERLINK(“https://”, B4, “/”, A4))

In this example, the product names are in column A, and the domain is in column B. We want to create clickable URL links by combining the product names with the website domains.

  • The formula =CONCAT(HYPERLINK("https://", B2, "/", A2)) cell, C2 combines the “https://” protocol with the domain in cell B2, a forward slash “/”, and the product name in cell A2 using the CONCAT function. The HYPERLINK function then converts the concatenated text into a clickable URL link.
  • Similarly, the formula in cell C3 combines the components for the URL link in cell C3.
  • The formula in cell C4 combines the components for the URL link in cell C4.

7️⃣ Example 7: Creating File Paths

Assume you have a dataset with file names and folder paths. You want to create full file paths by combining the folder paths with the file names.

ABC
1Folder PathFile NameFull Path
2C:\Documents\File1.docx=CONCAT(A2, B2)
3D:\Reports\File2.xlsx=CONCAT(A3, B3)
4E:\Projects\File3.pptx=CONCAT(A4, B4)

In this example, the folder paths are in column A, and the file names are in column B. We want to create full file paths by combining the folder paths with the file names.

  • The formula =CONCAT(A2, B2) in cell C2 concatenates the folder path in cell A2 with the file name in cell B2, resulting in “C:\Documents\File1.docx.”
  • Similarly, the formula in cell C3 combines the folder path in cell A3 with the file name in cell B3.
  • The formula in cell C4 combines the folder path in cell A4 with the file name in cell B4.

These examples demonstrate the versatility of the CONCAT function when nested with other functions commonly used in business scenarios. Combining the CONCAT function with other functions allows you to create customized text strings for various purposes, such as generating email addresses, invoice numbers, URL links, and file paths.

Part 3: Tips and Tricks

  • Use quotation marks to enclose static text or characters within the CONCAT function.
  • Include any desired separators within the CONCAT function, such as spaces, commas, or other symbols.
  • To create line breaks in the concatenated text, use the CHAR function with the line break code (e.g., CHAR(10)).
  • If you have many values to concatenate, consider using the CONCATENATE or TEXTJOIN functions, which can handle more arguments.
  • Use cell references to concatenate values from different cells dynamically.
  • Check for any leading or trailing spaces in the concatenated text strings, as they may affect the desired output. You can use the TRIM function to remove excess spaces if needed.
  • Double-check the result of the CONCAT function to ensure that the concatenated text is in the expected format.

The CONCAT function provides a convenient way to combine text strings or cell values in various business scenarios, such as creating full names, addresses, product codes, or customized messages.