Excel 多列组合内容循环展开
某表格 A 列是编号,其他列是用逗号分隔的意义不同的分类列
A |
B |
C |
D |
E |
F |
G |
|
1 |
Assembly# |
ProductType |
Unit Config |
Nominal Capacity |
Supply Voltage |
Generation |
Case Construction |
2 |
3H1012290001 |
CM |
D,P |
24,36 |
F |
A |
A,B |
3 |
3H1012290002 |
CM |
D,P |
48,60 |
F |
A,B |
A,B |
4 |
3H1012290003 |
CM |
D,P |
24,36 |
B,C,D,E |
A |
A,B |
要求展开各分类列,并互相组合。比如第一条数据的处理结果
A |
B |
C |
D |
E |
F |
G |
|
6 |
Assembly# |
ProductType |
Unit Config |
Nominal Capacity |
Supply Voltage |
Generation |
Case Construction |
7 |
3H1012290001 |
CM |
D |
24 |
F |
A |
A |
8 |
3H1012290001 |
CM |
D |
24 |
F |
A |
B |
9 |
3H1012290001 |
CM |
D |
36 |
F |
A |
A |
10 |
3H1012290001 |
CM |
D |
36 |
F |
A |
B |
11 |
3H1012290001 |
CM |
P |
24 |
F |
A |
A |
12 |
3H1012290001 |
CM |
P |
24 |
F |
A |
B |
13 |
3H1012290001 |
CM |
P |
36 |
F |
A |
A |
14 |
3H1012290001 |
CM |
P |
36 |
F |
A |
B |
使用 SPL XLL,输入公式:
=spl("=E@b(?.(~.(~.split@c())).conj(eval($[xjoin(] / ~.($[~(] / # / $[)]).concat($[;]) / $[)])))",A2:G4)
函数 E@b()将表格的非列名部分转为序列。split@c 用逗号将字符串拆为序列。conj 合并成员。eval 把字符串当作代码动态执行。xjoin 将多个序列叉乘 / 组合起来。$[;] 是字符串的简写形式,等价于 "";""
https://stackoverflow.com/questions/78330335/un-consolidate-truth-table-in-excel
跟着练习一下…
英文版