索引并匹配多列

用户名

我有以下数据集,我正在尝试重新排序以进行Word邮件合并。我需要取消显示空单元格,并将数组中的用户名与它们所属的公司名称匹配。

即时通讯使用以下解决方案来匹配第一个条件

=INDEX(CompanyName,MATCH(1,MMULT(--(Attendee=G4),TRANSPOSE(COLUMN(Attendee)^0)),0))

但这意味着我必须先输入用户名,然后才能匹配公司

=INDEX(Attendee,MATCH(0,COUNTIF($G$4:I4,list),0))

给我用户名的水平列表....但我需要它以垂直格式列出

ecompany name, user1, user2, user3, user4, user5, user6, user7
company1, bob, sue, dave, , ,john, mary
company2, dave, barry, steve, dan, , , pete

我希望数据出现在两列中以进行邮件合并

Company Name, User
company1, bob
company1, sue
company1, dave
company1, john
company1, mary
company2, dave
company2, dave
company2, barry
company2, steve
company2, dan
company2, pete

我希望这是有道理的?

在此处输入图片说明

这是我在示例中寻找的结果。不幸的是,它需要先填充第一列中的名称,然后才能与用户匹配。

输出样本:

输出样本

亚历克斯·M

好的。这仍然是一种“愚蠢”的方式,但是它只需要一个简单的手动步骤,并且实际上符合规范,因为它可以按要求在两列中显示您的结果。

数据: 数据

步骤1:

我定义了命名范围COMPANIES F2:F99和NAMES L2:AB99

第2步:

这是您的输出: 输出

在B列中包含公式:

=INDEX(NAMES,ROUNDUP((ROW()-1)/17,0),MOD(ROW()-2,17)+1)

It's just an nth-column/every n rows formula with n manually set to 17 (you could easily change that hard coded value or replace it with some kind of count function or a cell reference to a count function on your data sheet, etc etc as needed). It has to start in the second row (as shown in example) or else the offsets of the ROW() calls will need to be adjusted. But placed on a new sheet in cell B2, this formula will copy down, and read the first 17 columns of the first row of the named range NAMES, then the first 17 columns of the second row, and so forth.

STEP 3:

I wrote A2 with a half-baked version of the same formula to just get the first row of the named range 17 times, then the second row etc:

=INDEX(COMPANIES,ROUNDUP((ROW()-1)/17,0))

可以将其重写为索引匹配,以获取与在步骤2中检索到的“与会者姓名”值相对应的“公司名称”值,但是在此用例中,我没有看到该实用程序。

第四步:

这是愚蠢的部分...拿走您的输出表,全选,复制,粘贴值,过滤器,删除B列中带有0的行,删除过滤器,重新排序,鲍勃是您的叔叔。

后记

我肯定可以使用VBA中的for循环更干净地完成此操作。您可能甚至可以在此子项目中的其他问题中找到可以快速适应此确切用例的代码。我很自信,没有第4步就可以用比我更专业的人写的一个不错的公式来完成。幸运的是,无论您的与会者列表多大,第4步仅需10秒钟左右,因此在这种情况下,可以快速执行n项工作。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章