Excel:单列数据到多行
我有以下内容将行复制成多行,其中字段与逗号分开。
scriptnm | 表名称 |
---|---|
scripta.ksh | db.table1,db.table2 |
scripta.exp | db.table4 |
to替换如下:
scriptnm | table name |
---|---|
scripta.ksh | db.table2 |
scripta.ksh | db.table2 |
scripta.exp | db.table4 |
我可以尝试将行分开使用逗号定界符的列,但以下行不应影响。
更新的重复输入:
scriptnm | 表名称 |
---|---|
scripta.ksh | |
scriptb.ksh | db.table2 |
scriptc.exp | db.table3 |
scriptd.expd.exp | db.table4,db.table5 |
scripte.exp | |
scriptf.exp | db.table9 |
scriptg.exp | db.table10,db.table11,db.table13 |
scripth.exp.exp | db.table20,db。 table21,db.table23,db.table34 |
I have a below thing to replicate the rows into multiple rows where the fields are separated with comma.
SCRIPTNM | TABLE NAME |
---|---|
scriptA.ksh | DB.TABLE1, DB.TABLE2 |
scriptA.exp | DB.TABLE4 |
to replace as below:
SCRIPTNM | TABLE NAME |
---|---|
scriptA.ksh | DB.TABLE2 |
scriptA.ksh | DB.TABLE2 |
scriptA.exp | DB.TABLE4 |
I can try to split the rows to columns using comma delimiter, but the below rows should not effect.
Updated relistic input:
SCRIPTNM | TABLE NAME |
---|---|
scriptA.ksh | |
scriptB.ksh | DB.TABLE2 |
scriptC.exp | DB.TABLE3 |
scriptD.exp | DB.TABLE4,DB.TABLE5 |
scriptE.exp | |
scriptF.exp | DB.TABLE9 |
scriptG.exp | DB.TABLE10,DB.TABLE11,DB.TABLE13 |
scriptH.exp | DB.TABLE20,DB.TABLE21,DB.TABLE23,DB.TABLE34 |
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
基于公式的
excel 2010
的解决方案,标签:假设:
a1中的数据:b3
(第1行中的标题)b2:b2:b3
>在
f2
中这个数组公式:
= if(rows(b $ 2:b2)> sum(1+len(b $ 2:b $ 3)-len(替代(b $ 2:b $ 3,“,”,“,”,“”)),“” ,索引($ 2:A $ 3,IFERROR(1+匹配(行)(b $ 2 :b2)-1/2,mmult(n(b $ 2:b $ 3)> = transpose(row(b $ 2:b $ 3))),1+len(b $ 2:b $ 3) - len(替代) (b $ 2:b $ 3,“,”,“”))),1)))
复制直到开始获取结果的空白。
f2
中的非阵列公式:= if(f2 =““”,“”,TRIM(MID(index(index(b $ 2:B $ 3)) $ 3,0)),“,”,rept(“”,99),99*(countif(f $ 2:f2,f2)-1)-1)+1,99))))
已复制根据需要。
Formula-based solution for
Excel 2010
, as tagged:Assuming:
A1:B3
(with headers in row 1)B2:B3
does not contain any empty cellsThis array formula in
F2
:=IF(ROWS(B$2:B2)>SUM(1+LEN(B$2:B$3)-LEN(SUBSTITUTE(B$2:B$3,",",""))),"",INDEX(A$2:A$3,IFERROR(1+MATCH(ROWS(B$2:B2)-1/2,MMULT(N(ROW(B$2:B$3)>=TRANSPOSE(ROW(B$2:B$3))),1+LEN(B$2:B$3)-LEN(SUBSTITUTE(B$2:B$3,",","")))),1)))
Copy down until you start to get blanks for the results.
Non-array formula in
F2
:=IF(F2="","",TRIM(MID(SUBSTITUTE(INDEX(B$2:B$3,MATCH(F2,A$2:A$3,0)),",",REPT(" ",99)),99*(COUNTIF(F$2:F2,F2)-1)+1,99)))
Copied down as required.
您可以使用
电源查询
在Windows Excel 2010+和Office 365 Excel中获得所需的输出,然后data =>获取& transform =>从表/范围
或从表格中
home =>高级编辑器
应用步骤
窗口,更好地了解算法和步骤m代码
You can obtain your desired output using
Power Query
, available in Windows Excel 2010+ and Office 365 ExcelData => Get&Transform => From Table/Range
orFrom within sheet
Home => Advanced Editor
Applied Steps
window, to better understand the algorithm and stepsM Code
基于公式的替代解决方案,(阵列公式需要用
ctrl+shift+Entry+Enter
)•单元格中使用的公式
d2
- >要获取 scriptnm•单元格中使用的公式
e2
- >要获取表名或另一种方式,
•
g2
中使用的公式 - >要获取 scriptnm•单元格中使用的公式
h2
- >获取表名Formula based alternative solutions, (Array Formulas needs to be keyed with
CTRL+SHIFT+ENTER
)• Formula used in cell
D2
--> To Get SCRIPTNM• Formula used in cell
E2
--> To Get TABLE NAMEOr, One more way,
• Formula used in cell
G2
--> To Get SCRIPTNM• Formula used in cell
H2
--> To Get TABLE NAME