使用Vlookup/宏进行转置 [英] Using Vlookup/Macros to Transpose

查看:97
本文介绍了使用Vlookup/宏进行转置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Excel中,我在每行的单独列中具有唯一的人员及其各种角色的列表,如下所示:

In Excel, I have a unique listing of people and their various roles that they hold in separate columns within each row as following:

名称  角色 角色 角色 角色 角色
约翰        B     C    空   空
简    D    C    空    空   空
丽莎       B     C      F     G

Name     Role     Role     Role     Role     Role
John         A         B           C        null       null
Jane         D         C         null        null       null
Lisa         A         B           C          F          G

我想为每个唯一的名称"转置所有角色,以使名称-角色"的每种组合都有一行,如下所示:

I want to transpose all the roles for each unique 'Name' so that there is a row for each combination of Name - Role as follows:

名称角色
约翰   A
约翰   B
约翰   C
简   D
简   C
丽莎   A
丽莎   B
丽莎   C
丽莎   F
丽莎   G

Name    Role
John      A
John      B
John      C
Jane      D
Jane      C
Lisa      A
Lisa      B
Lisa      C
Lisa      F
Lisa      G

是否可以使用功能或宏的任何组合来在另一张工作表或同一电子表格中获得此输出?即使转置的行包含空值,我也可以删除所有结尾为空值的行.我大约有30多个用户,许多人要尝试分离20多个角色,因此,如果有自动化的方法,这可以节省我的时间.

Is there any combination of functions or macros I can utilize to get this output in another sheet or the same spreadsheet? Even if the transposed rows includes null values, I can go in and delete all rows with blank values at the end. I have about 30+ users and many have 20+ roles that I'm trying to separate so this may save me time if there's an automated way to do it.

推荐答案

在H2中:

=OFFSET($A$1,CEILING((ROW()-1)/COUNTA($B$1:$F$1),1),0)

在I2中:

=VLOOKUP(H2,$A$2:$F$4,COUNTIF(H$2:H2,H2)+1,FALSE)

把两者都填满.

这篇关于使用Vlookup/宏进行转置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆