将某些Excel行拆分为新列

dohp0rv5  于 2023-06-25  发布在  其他
关注(0)|答案(3)|浏览(140)

我有一个Excel文件,其中包含三列(A-C列)下的500多行数据。基于列A的值,我想将列A-C中的一些行移动到新的三列中。有没有什么公式可以做到这一点?
之前
| 一个|B| C类|
| - -----|- -----|- -----|
| 1|五十一|八十一|
| 1|六十一|九十一|
| 2|五十二|八十二|
| 2|七十二|九十二|
| 3|五十三|八十三|
| 3|七十三|九十三|
之后
| 一个|B| C类|一个|B| C类|一个|B| C类|
| - -----|- -----|- -----|- -----|- -----|- -----|- -----|- -----|- -----|
| 1|五十一|八十一|2|五十二|八十二|3|五十三|八十三|
| 1|六十一|九十一|2|七十二|九十二|3|七十三|九十三|
谢谢你。

gfttwv5a

gfttwv5a1#

下面的行吗?

E1中的公式:

=DROP(REDUCE(0,{1,2,3},LAMBDA(x,y,HSTACK(x,FILTER(A:C,A:A=y)))),,1)
eqoofvh9

eqoofvh92#

隔行HStack

公式

=LET(table,A1:C10,we,"",
    h,TAKE(table,1),d,DROP(table,1),
    r,ROWS(d),c,COLUMNS(d),
    rr,INT((r+1)/2),tc,rr*c,
    rh,INDEX(h,MOD(SEQUENCE(,tc)-1,c)+1),
    rs,VSTACK(SEQUENCE(rr,,,2),SEQUENCE(r-rr,,2,2)),
    cs,SEQUENCE(,c),
    rd,WRAPROWS(TOROW(INDEX(d,rs,cs)),tc,we),
VSTACK(rh,rd))
  • 如果你想隐藏零,你可以在最后一行用IF(rd=0,"",rd)替换rd。如果值不是数字,这一点尤其有用。
    变量
table - the table range
we    - wrap error - what to return if an odd number of data rows
h     - headers
d     - data
r     - number of data rows
c     - number of columns
rr    - about half (e.g. 4 for 7) of the data rows
tc    - number of total resulting columns
rh    - resulting headers
rs    - resulting data row sequence
cs    - resulting data column sequence
rd    - resulting data
nx7onnlm

nx7onnlm3#

另一种替代方法(不使用LAMBDA()helper)

·单元格E2中使用的公式

=LET(
       a,A2:C7,
       b,COLUMNS(a),
       c,SEQUENCE(ROWS(a)),
       d,TOROW(SEQUENCE(,b)+TOCOL(FILTER(c,ISODD(c))-{1,0},,1)*b),
       e,WRAPROWS(d,MAX(TAKE(a,,1))*b),
       INDEX(TOCOL(a),e))

相关问题