Search code examples
google-sheetstransposearray-formulasgoogle-sheets-querytextjoin

Merge all cells to one cell and separate with comma


I use Google Sheets, and I want to get data and create one new cell.

Example:

I have 300 rows and 4 columns, like:

1|3|2|4

5|7|6|8

9|11|10|12

...

297|299|298|300

and one cell that I need in result:

1,3,2,4,5,7,6,8,9,11,10,12...297,299,298,300

enter image description here


Solution

  • =SUBSTITUTE(TRIM(QUERY(TRANSPOSE(QUERY(TRANSPOSE(A2:D),,999^99)),,999^99)), " ", ", ")
    

    0

    ______________________________________________________

    but if you want just numbers from 1 - 300 in CSV then:

    =ARRAYFORMULA(JOIN(", ", ROW(A1:A300)))