且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将单列拆分为多列,每列1000行

更新时间:2023-02-02 22:32:31

  = ARRAYFORMULA(VLOOKUP(TRANSPOSE(SEQUENCE(ROUNDUP(COUNTA(A2:A)/3),3,ROW(A2))),{ROW(A2:A),A2:A},2,0)) 

  • SEQUENCE 创建具有3列的连续数字数组
  2 3 45 6 78 9 10 

  • TRANSPOSE 使其组成一个具有3行从上到下计数的数组:
  2 5 83 6 94 7 10 

  • VLOOKUP 创建的数组,以便使用人为创建的数组将人为创建的数字替换为其行值: {ROW(A2:A),A2:A}
 红色绿色洋红色蓝色粉色棕色黄色橙色黑色 

I have an extremely large column of data that I want to split into multiple columns of 1000 rows each. I have combed the internet for any possible answer, and am unable to find a solution. Example: Columns Before

I want to take the above column and split it into multiple columns of 3 rows, so that it resembles:

Columns After

I realize something like this would require a script. Any ideas? I've done it in Excel before, but not Google Sheets.

=ARRAYFORMULA(VLOOKUP(TRANSPOSE(SEQUENCE(ROUNDUP(COUNTA(A2:A)/3),3,ROW(A2))),{ROW(A2:A),A2:A},2,0))

  • SEQUENCE to create a sequential array of numbers with 3 columns
2   3   4
5   6   7
8   9   10

  • TRANSPOSE it to make a array with 3 rows counting from top to bottom:
2   5   8
3   6   9
4   7   10

  • VLOOKUP the created array to substitute artificial created numbers to their row values using a artificially created array: {ROW(A2:A),A2:A}
Red     Green   Magenta
Blue    Pink    Brown
Yellow  Orange  Black