VLOOKUP MATCH返回多个值 [英] VLOOKUP MATCH with returning multiple values

查看:440
本文介绍了VLOOKUP MATCH返回多个值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  ColumnA(所有客户)ColumnB(电子邮件)ColumnC(特定客户)

CustNO MailAddress CustNO
1 test@test.com 2
2 test2@test2.com 1
test3@test3.com 1

我使用下面的函数来返回ColumnB的值,当ColumnA的值匹配一行ColumnC时:

  = VLOOKUP (C2; A2:A520; MATCH(B1; A1:C1))

问题是, ColumnC可以包含ColumnA的多个值,如上例所示。



上面的函数只返回ColumnB的值,只有ColumnA的第一个匹配和ColumnC。任何想法如何为多个返回值返回所有值,如上例所示,ColumnC包含具有CustNO 1的多行。

解决方案

您需要使用索引和小函数来提取第一,第二,第三...匹配值。

  = IFERROR(INDEX($ A $ 2:$ C $ 250 SMALL(IF(($ A2:$ A $ 250 = $ C $ 2),ROW($ A $ 2:$ A $ 250)-1),ROW(1 :1)),2),)

重要提示:use CTRL + SHIFT + ENTER 当输入此公式时,使其成为数组公式。 ROW(1:1)提取第一个匹配,这将变为2:2,3:3等自动填充。



我不知道从你想要显示结果的问题中,但我建议你从C列中取出唯一值,并将它们转置到新工作表的顶部,然后在每个值下面放置查找公式,以便获得emai列表l每个客户号码的地址。

ColumnA (All customers)     ColumnB (E-mail)     ColumnC (Specific customers)

CustNO                      MailAddress          CustNO
1                           test@test.com        2
2                           test2@test2.com      1
                            test3@test3.com      1

I am using the following function to return the value of ColumnB when the value of ColumnA matches in a row of ColumnC:

=VLOOKUP(C2;A2:A520;MATCH(B1;A1:C1))

The problem is, that ColumnC can contain multiple values of ColumnA as shown in the above example.

The function as above is only returning the value of ColumnB, for only the first match found of ColumnA and ColumnC. Any idea how I can return all of the values for also the multiple returning values, as shown in above example, ColumnC contains multiple rows with CustNO 1.

解决方案

you need to use the index and small functions to extract the 1st, 2nd, 3rd ... matching values.

=IFERROR(INDEX($A$2:$C$250,SMALL(IF(($A2:$A$250=$C$2),ROW($A$2:$A$250)-1),ROW(1:1)),2),"")

IMPORTANT: use CTRL+SHIFT+ENTER when entering this formula to make it an array formula.

note that this formula uses ROW(1:1) to extract the first match, this will change to 2:2, 3:3 etc as to auto fill down.

I don't know from your question where you want to display the results but I would suggest that you take the unique values from column C and and transpose them across the top of a new sheet and then put the lookup formula below each value so you have a list of email addresses for each customer number.

这篇关于VLOOKUP MATCH返回多个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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