21

enter image description here

I want to concatenate/combine columns A, B and C into column D as displayed.

The number of filled entries in A, B and C will vary over time, so absolute cell addresses cannot be used.

What formula could I put into D1 to fill the column as illustrated?

2
  • I'm aware that "append" may have been better vocabulary than "concatenate." Since concatenate is something you usually do with individual values.
    – Paulb
    Mar 6, 2016 at 17:31
  • 1
    Maybe best answer to merge for statistical manipulation here where you do not need to filtering here webapps.stackexchange.com/a/69049/66725 So just use = {A1:A; B1:B}. Etc to count unique matches in two columns = count(unique(A1:A; B1:B})). Nov 10, 2016 at 20:42

4 Answers 4

12

You need to filter down to non-empty cells, and then stack the results together:

={filter(A:A, len(A:A)); filter(B:B, len(B:B)); filter(C:C, len(C:C))}

This is the same as this answer by grayob which is unfortunately buried under outdated answers.

1
  • 1
    Worked perfectly. I saw that Q and I focused on the vmerge, unsuccessfully. In that Q, grayob's answer is better than the accepted answer. Tks.
    – Paulb
    Mar 6, 2016 at 17:24
16

A shorter version of the formula in this other answer

=FILTER({A:A;B:B;C:C}, LEN({A:A;B:B;C:C}))
6

A little longer, but can be constrained to a limited array (not whole columns):

=transpose(split(textjoin("|",1,{A1:C4}),"|"))

where the order does not matter. Where it does:

=transpose(split(textjoin("|",1,{A1:A4;B1:B4;C1:C4}),"|"))
2
  • 3
    This is my favourite solution for this problem, it doesn't require naming all the columns. You can also do SORT for the first solution where you want it to be alphabetised.
    – Lou
    Jan 25, 2020 at 11:37
  • Yep, this is the one! It takes in 1 range, not many ranges. Nov 13, 2020 at 20:59
1

Now that Google Sheets has the FLATTEN and QUERY functions, this is an option:

=query(flatten(transpose(A1:C4)),"where Col1 is not null")

This will work with whole-column ranges, although there could be performance issues with extremely large spreadsheets:

=query(flatten(transpose(A:C)),"where Col1 is not null")

enter image description here


The QUERY function also supports sorting:

=query(flatten(A:C),"where Col1 is not null order by Col1 desc")

with order by

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.