Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excel - Concatenate many columns

I'm trying to concatenate a bunch of columns in Excel. I know I can manually do with:

=A1&", "&B1&", "&C1 (and so on)

but I have about 40 columns, and I'm looking for a way to streamline this process.

Thanks in advance for any help!

like image 510
psorensen Avatar asked Sep 02 '14 16:09

psorensen


People also ask

How do you CONCATENATE 50 columns in Excel?

For this, select all the columns (select first column, press and hold shift key, click on the last column) and press right click and then select “Merge”. After that, from Merge window, select space as a separator and name the column. In the end, click OK and click on “Close and Load”.

How do you CONCATENATE 20 columns in Excel?

CONCATENATE Excel Range (Without any Separator)Select the entire formula and press F9 (this converts the formula into values). Remove the curly brackets from both ends. Add =CONCATENATE( to the beginning of the text and end it with a round bracket). Press Enter.


1 Answers

As a user function taking a range

Public Function ClarkeyCat(ByRef rng As Range) As Variant

Dim c As Range
Dim ans As Variant

For Each c In rng

If (c.Value <> "") Then
    ans = IIf(ans = "", "", ans & ",") & c.Value
End If

Next

ClarkeyCat = ans
End Function

Changing the Variant types, if you need to (to string, most likely).

Use like this:

enter image description here

like image 66
Rusan Kax Avatar answered Nov 03 '22 13:11

Rusan Kax