简体   繁体   English

如何在一个范围内的单元格中搜索项目?

[英]How can I search for an item within a cell that's also in a range?

I have Table A :我有表 A

╔═══╦═════╦═════════════╦══════════════════╗
║   ║  a  ║      b      ║         c        ║
╠═══╬═════╬═════════════╬══════════════════╣
║ 1 ║ ID  ║ LIST VALUES ║ Table B Values   ║
╠═══╬═════╬═════════════╬══════════════════╣
║ 2 ║ 123 ║ 231,583     ║ eggs,bacon       ║
╠═══╬═════╬═════════════╬══════════════════╣
║ 3 ║ 789 ║ 518,732     ║ bacon,bread      ║
╠═══╬═════╬═════════════╬══════════════════╣
║ 4 ║ 101 ║ 55,38       ║ tomato,onion     ║
╠═══╬═════╬═════════════╬══════════════════╣
║ 5 ║ 213 ║ 894,231     ║ ham,eggs         ║
╠═══╬═════╬═════════════╬══════════════════╣
║ 6 ║ 141 ║ 55,38,894   ║ tomato,onion,ham ║
╠═══╬═════╬═════════════╬══════════════════╣
║ 7 ║ 516 ║ 548,43      ║ milk,butter      ║
╚═══╩═════╩═════════════╩══════════════════╝

And I have Table B :我有表 B

╔═══╦═════╦═════════════╗
║   ║  a  ║      b      ║
╠═══╬═════╬═════════════╣
║ 1 ║ ID  ║ LIST VALUES ║
╠═══╬═════╬═════════════╣
║ 2 ║ 231 ║ eggs        ║
╠═══╬═════╬═════════════╣
║ 3 ║ 518 ║ bacon       ║
╠═══╬═════╬═════════════╣
║ 4 ║ 732 ║ bread       ║
╠═══╬═════╬═════════════╣
║ 5 ║ 55  ║ tomato      ║
╠═══╬═════╬═════════════╣
║ 6 ║ 38  ║ onion       ║
╠═══╬═════╬═════════════╣
║ 7 ║ 894 ║ ham         ║
╠═══╬═════╬═════════════╣
║ 8 ║ 548 ║ milk        ║
╠═══╬═════╬═════════════╣
║ 9 ║ 43  ║ butter      ║
╚═══╩═════╩═════════════╝

These are representations of the data I have, and what I need help with.这些是我拥有的数据的表示,以及我需要帮助的内容。 The actual data is a lot longer than these tables, and the delimited items can be very long.实际数据比这些表长很多,分隔的项目可能很长。

What I'm trying to do is populate Table A , Column C .我想要做的是填充表 A列 C I need to search the items from TABLE B , Column A for the listed items in TABLE A , Column B within the cell through the whole range.我需要在整个范围内搜索TABLE B列 A中列出的项目的单元格内的TABLE A列 B中的项目。

I guess this can be done vice versa as well.我想这也可以反之亦然。 I am familiar with INDEX-MATCH function, but I'm not sure how to add searching within the cell.我熟悉 INDEX-MATCH function,但我不确定如何在单元格中添加搜索。

Use TEXTJOIN and ISNUMBER/SEARCH :使用TEXTJOINISNUMBER/SEARCH

=TEXTJOIN(",",TRUE,IF(ISNUMBER(SEARCH(","&$G$2:$G$9&",",","&B2&",")),$H$2:$H$9,""))

在此处输入图像描述

If you have Windows Excel, try:如果您有 Windows Excel,请尝试:

C2: =TEXTJOIN(",",TRUE,VLOOKUP(FILTERXML("<t><s>"&SUBSTITUTE(B2,",","</s><s>")&"</s></t>","//s"),$G$2:$H$9,2,FALSE))

Table A表 A

在此处输入图像描述

Table B表 B

在此处输入图像描述

Results结果

在此处输入图像描述

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

相关问题 如何在一个范围内获得单元格的位置? - How do I get a cell's position within a range? 搜索单元格范围内的数字 - Search for a number within cell range 一旦单元格发生变化,如何让范围内的单元格进行硬编码? - How can I get a cell within a range to hardcode once the cell changes? 如何在不同的Excel工作表中的某个范围内搜索单元格内容 - How to search a Cell Content within a Range in different Excel Sheets 如何在搜索范围内搜索? - How do I search within a searched range? 如何在元胞数组中搜索子字符串并返回该元胞中的整个字符串? - How can I search for a substring within a cell array and return the whole string in that cell? 当单元格的验证列表中已包含值时,如何从该列表中删除该项目? - How can I remove an item from a cell's validation list when the cell already contains a value on that list? 如何在C#中的单元格(边框)颜色上搜索Excel范围? - How to search an excel range on cell's (border) colour in C#? 如何在一个范围内的列中找到第一个空单元格,并在后续公式中使用行引用? - How can I find the first empty cell in a column within a range, and use the row-reference in subsequent formulas? 如何引用非连续命名范围内的特定单元格? - How can I refer to specific cell within non contiguous named range?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM