简体   繁体   English

使用数组在Excel中返回多个ID号

[英]Returning multiple ID numbers in Excel using an Array

I am working with a set of data in Excel that includes ID numbers and Account numbers. 我正在使用Excel中的一组数据,其中包括ID号和帐号。 Each ID number contains multiple account numbers. 每个ID号包含多个帐号。 I want to return each Account number associated with each ID number vertically. 我想垂直返回与每个ID号关联的每个帐号。

I have done research and came up with an array formula that works for the first ID number but does not work for the rest. 我已经进行了研究,并提出了适用于第一个ID号但不适用于其他ID的数组公式。 I have created a sample of my data to share. 我已经创建了一个数据共享样本。

{=INDEX($E$2:$E$5, SMALL(IF(($H2=$A$2:$C$5), MATCH(ROW($A$2:$C$5), ROW($A$2:$C$5)), ""), ROWS($A$1:A1)))}

I am getting a #NUM! 我得到一个#NUM! error in the rest of the cells. 其余单元格中的错误。 Any help would be greatly appreciated. 任何帮助将不胜感激。

sample data - formula result - desired result

样本数据-公式结果-所需结果

Using your provided data setup like so: 像这样使用提供的数据设置:

在此处输入图片说明

In cell H2 and copied down is this (regular) formula (assumes ID #s are actually numbers as shown in your provided sample data): 在H2单元格中,此(常规)公式向下复制(假定ID号实际上是数字,如提供的示例数据中所示):

=IF(ROW(H1)>COUNTA($A$2:$C$5),"",SMALL($A$2:$C$5,ROW(H1)))

Then in cell I2 and copied down is this ( array ) formula: 然后在单元格I2中并向下复制以下( 数组 )公式:

=IF(H2="","",INDEX(E:E,SMALL(IF($A$2:$C$5=H2,ROW($A$2:$C$5)),COUNTIF(H$2:H2,H2))))

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

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