Excel Concatenating Columns
Concatenating Columns in Excel
We frequently come up with a situation where we have data stored in multiple columns and all we wanted is to store it in one single column row by row.
For example, you have a full view table which contains different columns named as Emp ID, First Name, Last Name, Address, City, Postal Code, Salary. You wanted to combine the First Name and Last Name with Space as a separator between them or you wanted to combine the Address along with City and Postal Code details so that you can have Address in one single cell which could be printed on the envelope in case you send them a letter.
What you can do in such scenarios? If you are not sure what to do in such cases, this article is for you.
In this article, we are about to see, how can we concatenate the data from two or more columns using concatenate function as well as ampersand (&) operator
As the word itself mean as per the English literature (Concatenate = link (things) together in a chain or series), Concatenation is a process in excel which allows you to join two or more columns containing strings cell by cell (row by row more precisely) with the help of certain separators/delimiters.
How to Concatenate Columns in Excel?
We have two ways in excel to concatenate the strings.
- Using CONCATENATE() Function
- Ampersand (&) Operator
We will see both methods of Concatenating Columns in Excel with some examples.
Concatenate Columns in Excel – Example #1
Concatenating two or more cells using CONCATENATE() Function –
Syntax for CONCATENATE in excel is :
=CONCATENATE(text1, [text2], [text3], …). Where text is most of the times cell reference value.
We can see that apart from the first argument the rest of them are enclosed in squared brackets. It’s an indication that these arguments are optional.
Let’s look at some of the examples!
Suppose we have two columns containing First name and Last Name of Employee in each respective column (B and C).
We can concatenate the two values (B2 and C2) under column D (named as Full Name) as follows:
=CONCATENATE(B2 , C2)
See the image below.
However, you can see that the First Name and Last Name are combined without any delimiter/separator. Please see the below image for realization.
You can see that there is no separator between First Name and Last Name in column D (Full Name).
We would like to have space between First Name and Last Name.
Fortunately, CONCATENATE in excel allows us to add delimiters as well as separators for customization of view.
See the below formula:
=CONCATENATE(B2, “ ”,C2)
You can easily recognize the difference between the previous formula and this one. There is a space included within quotations to add space between First and Last Name.
The result will be:
Note –
- We can use different delimiters within the CONCATENATE() function. Ex. Comma (“,”), hyphen (“-”), forward or backward slash, asterisk (*) etc.
Now as we have come up with the solution for concatenating two cells, let’s think on a broader picture and try to combine two columns. It’s just as simple as dragging the notification panel down of your smartphone.
You just need to drag the fill handle down, so that formula in D2 gets copied and pasted in subsequent cells.
Easy looking right?
There is another method to concatenate two or more than two columns in excel. Let’s have a look, it looks easier.
Concatenate Columns in Excel – Example #2
Concatenating two or more cells using ampersand (&) operator –
Ampersand (&) operator can also be used to concatenate two or more cells in excel. It works as same as CONCATENATE() function. This operator seems handier, as lazy people like me would like to type “&” other than CONCATENATE().
We will try to concatenate the same columns using ampersand operator with below syntax:
In cell D2, input the formula: =B2&C2
It will give you the following output:
The result will be:
It is ideal to have space between First Name and Last Name.
On the similar note of concatenating function, you can add separator/delimiter while using ampersand operator to concatenate two or more columns.
In cell D2, replace the previous formula with the new one and see the results: = B2&” ”&C2
We can drag the fill handle or use Ctrl + D (if there are no hidden cells between) to apply the formula to the entire column.
Easier to type & than CONCATENATE(), right?
Concatenate Columns in Excel – Example #3
Concatenating two or more strings with Line Breaks –
More often, you use separator/delimiter like a comma(,), space, forward/backward slashes (when you’ve to concatenate dates), asterisk(“*”), etc. to concatenate two or more strings. However, what if you have address details such as Street, City and Postal Code in different columns and you wanted to concatenate the same with line breaks so that the output should look like :
We can’t add a line break as a simple delimiter(like a comma, space etc.) in excel formula of CONCATENATE(). Therefore, we need to use special function CHAR() to provide ASCII code of line break (ASCII code is a code which represents English letters with each letter assigned a unique number between 0 to 127. For line break the ASCII code is 10). Please note that these codes are compatible with the Windows system.
Let’s have a look at an example:
We have 3 different columns containing address information. column A (Street), column B (City) and column C (Postal Code).
Let’s rename column D as Address and type the following formula under cell D2:
=CONCATENATE(A2, CHAR(10) , B2 , CHAR(10) , C2)
It gives the following result:
You can drag the formula to copy and apply it for all cells.
The result will look like this:
Things to Remember
- At least one text argument is required for CONCATENATE() function in excel.
- CONCATENATE() formula has a limit of 255 strings (6equivalent to 8,192 characters). You can’t go beyond that limit in a single CONCATENATE() formula.
- CONCATENATE() function always gives a string output no matter what the type of your input data is. Saying that, though your input data is of Numeric in nature, the output will always be a string.
- Arrays cannot be recognized by CONCATENATE() function. Each cell reference needed to be provided separately. Having said that, =CONCATENATE(B2:C2) cannot be used instead of =CONCATENATE(B2, C2).
- If at least one of the argument is not right or invalid in CONCATENATE() function, then excel will shoot an #VALUE! error towards the cell.
- #NAME? error appears in CONCATENATE() function when there are quotations missing while you are concatenating two or more Text values.
- The Last and the most important, if you are using Excel 2016 or above version, you are supposed to use CONCAT() function instead of CONCATENATE() as the latter is replaced by the successor and supposed to be there in all upcoming excel versions. CONCATENATE() is still there for any compatibility with previous excel versions, but Microsoft doesn’t assure whether it would be there in coming excel versions or not.
Recommended Articles
This has been a guide to Concatenate Columns in Excel. Here we discussed Concatenate columns in Excel and How to use Concatenate Columns in Excel using different methods in Excel along with practical examples and downloadable excel template. You can also go through our other suggested articles –