简体   繁体   English

将行转置为Excel

[英]Transpose rows to columns excel

I'm looking to transpose rows to columns, I tried with Transpose(Array) but could not achieve expected results. 我正在尝试将行转置为列,我尝试过Transpose(Array),但无法达到预期的结果。 Here is the sample data and expected results I'm looking out. 这是我正在寻找的示例数据和预期结果。

Sample Data: 样本数据:

Number  Name    Value
1001    description Unknown
1001    Code    0
1001    GNumber 232323
1001    DNumber 232323
1002    description Unknown
1002    GNumber 232323
1002    DNumber 232323
1003    description Unknown
1003    Code    0
1003    GNumber 232323
1003    ICode   123
1004    description Unknown
1004    GNumber 232323
1004    ExtCode 4000

Expected Results: 预期成绩:

Number  description Code    GNumber DNumber ICode   ExtCode
1001    Unknown 0   232323  232323      
1002    Unknown     232323  232323      
1003    Unknown 0   232323      123 
1004    Unknown     232323          4000

Thank you, 谢谢,

TDLR : create the table column & row header manually. TDLR:手动创建表的列和行标题。 then load values using an index() match() function inside. 然后使用内部的index()match()函数加载值。

Method : Assuming the 'Number' text is in A1, and your data fills in A2:C15. 方法:假设“数字”文本在A1中,并且您的数据填写在A2:C15中。


  1. [create the table column & row header ] [创建表的列和行标题]

select A2:A15 > copy > then paste in another empty sheet/file > paste > then select "remove duplicate" > copy the result > then paste in cell E2:E5 (same sheet as original data table.) 选择A2:A15>复制>然后粘贴到另一个空工作表/文件中>粘贴>然后选择“删除重复项”>复制结果>然后粘贴到单元格E2:E5中(与原始数据表相同)。

Do the same for column B. but need to transpose it. 对B列执行相同操作,但需要转置。 :

select B2:B15 > copy > then paste in another sheet/file > paste > then select "remove duplicate" > copy the result > then r-click on F1 > paste special : transpose . 选择B2:B15>复制>然后粘贴到另一个工作表/文件中>粘贴>然后选择“删除重复项”>复制结果>然后右键单击F1>粘贴特殊:转置。

Now you should have the table column & row header. 现在,您应该有了表格的列和行标题。


  1. [use 2 criteria index match (reference link ) + iferror (to display null if not found). [使用2个条件索引匹配(参考链接 )+ iferror(如果未找到,则显示null)。 ] ]

put this in F2, then drag until K5 . 将其放在F2中,然后拖动到K5。

=IFERROR(INDEX($C$2:$C$15,MATCH(1,INDEX(($E2=$A$2:$A$15)*(F$1=$B$2:$B$15),0,1),0)),"")

Done. 做完了

p/s : to understand how the index match work.. just need to start a read on simple example of index() match().. the formula here are the same but with additional tricks. p / s:了解索引匹配是如何工作的..只需要开始阅读index()match()的简单示例即可。这里的公式相同,但有其他技巧。

hope it helps. 希望能帮助到你。 ( : (:

This can be done in 2 ways. 这可以通过两种方式完成。

WITH STANDARD FORMULAS : In this case, you will use standard formulas, but to make this work, you need an extra column. 使用标准公式 :在这种情况下,您将使用标准公式,但是要进行此工作,您需要额外的一列。

First of all, you need to insert an extra column at start of your data, where you are going to concatenate the values of fields NUMBER and NAME. 首先,您需要在数据的开头插入一个额外的列,在此处您将串联字段NUMBER和NAME的值。 In my image I used =B2&C2 : 在我的图像中,我使用了=B2&C2

在此处输入图片说明

Then, to get the data, you can use a VLOOKUP that will search for the concatenated text, and if found, will get the value. 然后,要获取数据,可以使用VLOOKUP来搜索串联的文本,如果找到,则将获取值。 We combine this with an IFERROR to show "" if nothing found. 如果未找到,我们将其与IFERROR结合使用以显示""

=IFERROR(VLOOKUP($B19&C$18;$A$1:$D$15;4;FALSE);"")

And this will work, as you can see in the image above. 如上图所示,这将起作用。

WITH ARRAY FORMULAS : This way is a more complex formula, but the good thing is you don't need to add an extra column. 使用ARRAY FORMULAS :这种方式是一个更复杂的公式,但是好处是您不需要添加额外的列。

We combine MATCH and INDEX in array mode to get the value you want, and we use an IFERROR to show "" if nothing found: 我们在数组模式下将MATCH和INDEX结合起来以获得所需的值,如果没有找到,我们将使用IFERROR来显示""

在此处输入图片说明

The formula I used is: 我使用的公式是:

=IFERROR(INDEX($C$2:$C$15;MATCH($B22&C$21;$A$2:$A$15&$B$2:$B$15;0));"")

NOTE: : Because this in an array formula, it must be entered with CTRL + SHIFT + ENTER or it won't work! 注意::因为这是在数组公式中,所以必须使用CTRL + SHIFT + ENTER输入,否则它将不起作用!

I've uploaded both samples to my Gdrive in case you want to check the formulas and how do they work. 如果您想检查公式以及它们如何工作,我已经将两个示例都上传到了Gdrive中。

https://drive.google.com/open?id=1ke7L5W1Ii8TffR7HTPtPxnAHVwyDYymy https://drive.google.com/open?id=1ke7L5W1Ii8TffR7HTPtPxnAHVwyDYymy

Hope this helps!. 希望这可以帮助!。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM