Excel 多行表头的列转行

Excel中A3:F6是带表头的典型表格,但上面多了额外的两行表头:

|---|---------|---------|-------------|-------------|----------|----------|
| | A | B | C | D | E | F |
| 1 | | | Actuals | Actuals | Plan | Plan |
| 2 | | | FY20 | FY21 | FY20 | FY21 |
| 3 | Country | Owner | 1/1/2020 | 1/1/2020 | 1/1/2020 | 1/1/2020 |
| 4 | France | Richard | 100 | 150 | 80 | 160 |
| 5 | France | Martin | 120 | 140 | 130 | 140 |
| 6 | France | Pierre | 50 | 100 | 50 | 80 |

现在要将典型表格连同额外的两行表头同时进行列转行:

|----|-------------|-----------|-------------|----------|----------|-----------|
| | A | B | C | D | E | F |
| 9 | Country | Owner | Version | Year | Date | Value |
| 10 | France | Richard | Actuals | FY20 | 1/1/2020 | 100 |
| 11 | France | Richard | Actuals | FY21 | 1/1/2020 | 150 |
| 12 | France | Richard | Plan | FY20 | 1/1/2020 | 80 |
| 13 | France | Richard | Plan | FY21 | 1/1/2020 | 160 |
| 14 | France | Martin | Actuals | FY20 | 1/1/2020 | 120 |
| 15 | France | Martin | Actuals | FY21 | 1/1/2020 | 140 |
| 16 | France | Martin | Plan | FY20 | 1/1/2020 | 130 |
| 17 | France | Martin | Plan | FY21 | 1/1/2020 | 140 |
| 18 | France | Pierre | Actuals | FY20 | 1/1/2020 | 50 |
| 19 | France | Pierre | Actuals | FY21 | 1/1/2020 | 100 |
| 20 | France | Pierre | Plan | FY20 | 1/1/2020 | 50 |
| 21 | France | Pierre | Plan | FY21 | 1/1/2020 | 80 |

使用 SPL XLL,输入公式:

复制代码
=spl("=c=transpose(?2),?1.conj( (a=~).m(3:).(a.to(2)|c(#)|~))",A4:F6,C1:F3)

=spl("=c=transpose(?2),?1.conj( (a=~).m(3:).(a.to(2)|c(#)|~))",A4:F6,C1:F3)

transpose将表头 C1:F3 进行转置,conj 合并集合成员,~ 表示表格 A4:F6 每一行,m(3:) 表示从每行的第 3 个成员取到结尾。

相关推荐
刘_sy7 小时前
使用EasyExcel和多线程实现高效数据导出
java·excel·easyexcel·批量导出excel
PowerBI学谦12 小时前
Copilot:Excel中的Python高级分析来了
python·excel·copilot
E-iceblue2 天前
Python 合并 Excel 单元格
python·excel·合并
sszdzq2 天前
Excel 合并列数据
excel
prince_zxill2 天前
Excel中不用复杂公式根据指定X列的数值N复制整行数据N行简单方法
excel
VBAMatrix3 天前
DeepSeek操作Excel,实现图表自动化生成
运维·自动化·excel·wps·deepseek
一醉千秋3 天前
excel中单元格字符串提取数字累加
excel
VB.Net3 天前
19.4.9 数据库方式操作Excel
数据库·c#·excel
真就死难3 天前
CSV格式和普通EXCEL格式文件的区别
linux·excel
朵朵zeng3 天前
Excel文件的读取
python·excel