通过合并2列以形成唯一键的VLOOKUP [英] VLOOKUP by Combining 2 Columns to Form a Unique Key

查看:175
本文介绍了通过合并2列以形成唯一键的VLOOKUP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于下表,

我想在col C中查找值.由于col A和col B中的值不是唯一的,因此VLOOKUP失败.例如,VLOOKUP(1,table,3)返回5,从不返回1.

I want to look up the value in col C. Since the values in col A and col B are not unique, VLOOKUP fails. For example, VLOOKUP(1,table,3) returns 5 and never 1.

但是,cols A&的组合 B是唯一的.例如1blah = 5,而1foo = 1.

However, the combinations of cols A & B are unique. For example, 1blah = 5, while 1foo = 1.

如何使用cols A&的组合B作为唯一键,以返回col C中的对应值?

How can I use the combination of cols A & B as a unique key to return the corresponding value in col C?

我不确定是否应使用工作表功能或自定义VBA功能来实现.我尝试使用CONCATENATE生成唯一键,但这没有用,因为这会导致数字和字符串的组合.

I'm not sure if this should be implemented with worksheet functions or a custom VBA function. I tried using CONCATENATE to generate the unique key, but this did not work because this results in combinations of numbers and strings.

推荐答案

您可以使用数组公式:

=INDEX($C$1:$C$7,MATCH("1foo",$A$1:$A$7 & $B$1:$B$7,0))

只需在示例D1中选择,在公式栏中输入公式,然后按 CTRL + SHIFT + ENTER 对其进行评估

just select in example D1, enter formula in formula bar and press CTRL+SHIFT+ENTER to evaluate it

这篇关于通过合并2列以形成唯一键的VLOOKUP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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