简体   繁体   English

在具有多个匹配项的Excel列中查找单个值

[英]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 我的原始表是这样的

original 原版的

My list of account numbers looks like this 我的帐号列表如下所示

  • 217 1008 217 1008
  • 218 1008 218 1008
  • 219 1008 219 1008
  • 217 2009 217 2009
  • 218 2009 218 2009
  • 219 2009 219 2009
  • 218 3015 218 3015
  • 219 3015 219 3015
  • 217 4017 217 4017
  • 219 4017 219 4017

Expected results look like this 预期结果如下所示

results 结果

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? 谁能帮我吗?

If your Client and Accounts list is in seperate cells, you could use Countifs() : 如果您的客户和帐户列表位于单独的单元格中,则可以使用Countifs()

在此处输入图片说明

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? 如果您仅对少量的客户/帐户进行一次单次检查,也许仅对数据使用自动过滤器可能是一个更简单的解决方案?

If you Client and Accounts is in the same column, you can use this which tries to MATCH the concatenation of the row and column header (with space): 如果您的客户和帐户在同一列中,则可以使用此方法来尝试MATCH行和列标题(带空格)的串联:

=IF(NOT(ISERROR(MATCH($C4&" "&D$1,$A$2:$A$11,0))),"X","")

Eg: 例如:

在此处输入图片说明

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.

相关问题 在Excel中单列成多个? - Single Column into Multiple in Excel? 根据特定的列值,将单个Excel工作表转换为多个工作表 - Single Excel Sheet to Multiple Sheets, based on specific column value Excel-将数据从多行转置为具有匹配值的单列 - Excel - Transpose data from multiple rows to single column with matched value Excel 如果条件在两列获取值中匹配 - Excel If Condition matches in two column fetch value excel在单列中有多个平均值 - excel multiple average in single column Excel VBA:在命名表中的特定列上进行vLookup,如果它与多个条件和通配符匹配,则替换值 - Excel VBA: vLookup on a specific column in a Named Table and replacing value if it matches with multiple criteria and wildcard Excel:检查列中单个单元格的部分匹配 - Excel: Check for partial matches from column against single cell 如果内容与另一列相匹配,则希望在excel中循环浏览一列并突出显示填充每个单元格 - Looking to loop through a column in excel and highlight fill each cell if the content matches that of another column 计算与单个列中的多个条件匹配的列中的唯一值 - Counting unique values in a column that matches multiple criteria in a single column Excel检查列中的值是否始终与其旁边的列匹配 - Excel check that value in column is always matches the column next to it
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM