[英]Looking for a single value in an Excel column with multiple matches
I have a list of client numbers and I need to search through a list of account numbers to find out if the client has a particular account number in their file. 我有一个客户编号列表,我需要搜索一个帐户列表,以找出该客户文件中是否有特定的帐户编号。
My original sheet looks like this 我的原始表是这样的
My list of account numbers looks like this 我的帐号列表如下所示
Expected results look like this 预期结果如下所示
Originally, I concatenated the client and account numbers then did a VLOOKUP but I'm sure there's a better way. 最初,我将客户和帐号连接在一起,然后进行了VLOOKUP,但是我敢肯定有更好的方法。 Maybe using VBA instead of a formula in the worksheet.
也许使用VBA代替工作表中的公式。 Can anyone help me out?
谁能帮我吗?
As @pnuts says, a PivotTable will get you your results table, but it will soon get unwieldy if you have large numbers of clients/accounts. 正如@pnuts所说,数据透视表将为您提供结果表,但是如果您有大量客户/帐户,它将很快变得笨拙。 Your VLOOKUP of a CONCATENATEd value is a good way to go unless you don't want to modify the data.
除非您不想修改数据,否则将CONCATENATEd值设为VLOOKUP是一个好方法。
If you're only doing it as a single shot check on a small number of clients/accounts, perhaps just using the auto-filters on the data might be a simpler solution? 如果您仅对少量的客户/帐户进行一次单次检查,也许仅对数据使用自动过滤器可能是一个更简单的解决方案?
I will assume the the table shown in results starts in cell A1, so your formula will be typed in B3 and copied right and down. 我将假设结果中显示的表格从A1单元格开始,因此您的公式将在B3中键入并向右和向下复制。 I will also assume you account list is in a named range
Acct
. 我还将假设您的帐户列表在
Acct
命名范围内。
=IF(MATCH($A3&" "&B$14,Acct)>0,"X","")
Copy this to all cells in B3:E5 in your example. 在您的示例中,将其复制到B3:E5中的所有单元格中。
Here's another way, using Index/Match
. 这是使用
Index/Match
的另一种方法。 Break your 217 1008
column into two, using Text to Columns, Space Delimiter. 使用“文本到列,空格分隔符”将
217 1008
列分成两部分。 Then say these are in range J1:J10 ( 217, 218, etc.
), and in K1:K10 is 1008, 1009, etc.
: 然后说它们在J1:J10的范围内(
217, 218, etc.
),在K1:K10的范围内是1008, 1009, etc.
:
=IF(NOT(ISERROR(INDEX($J$1:$J$10,MATCH($A2&B$1,$J$1:$J$10&$K$1:$K$10,0)))),"X","")
(enter as array with CTRL+SHIFT+ENTER ) (使用CTRL + SHIFT + ENTER输入数组)
Where A2 is the start of your 217
numbers going down, and B1 is the 1008
start going right. 其中A2是您的
217
数字下降的开始,而B1是1008
开始右拐。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.