跳到主要内容

如何检查单元格是否包含Excel中的几个值之一?

假设您在A列中有一个文本字符串列表,现在,您想测试每个单元格是否包含基于另一个范围D2:D7的多个值之一。 如果它包含D2:D7中的任何特定文本,它将显示True,否则将显示False,如下面的屏幕截图所示。 本文将讨论如果单元格包含另一个范围内的多个值之一,则如何识别该单元格。


检查单元格是否包含公式列表中的多个值之一

若要检查单元格内容是否包含另一个范围内的文本值,请使用以下公式,请这样做:

将下面的公式输入到要查找结果的空白单元格(例如B2)中,然后将填充手柄向下拖动到要应用此公式的单元格中,如果该单元格的另一个文本值特定范围,它将为True,否则为False。 看截图:

=SUMPRODUCT(--ISNUMBER(SEARCH($D$2:$D$7,A2)))>0

提示:

1.如果要使用“是”或“否”来表示结果,请应用以下公式,您将根据需要获得以下结果,请参见屏幕截图:

=IF(SUMPRODUCT(--ISNUMBER(SEARCH($D$2:$D$6,A2))),"Yes","No")

2.在上述公式中, D2:D7 是您要基于其检查单元格的特定数据范围,并且 A2 是您要检查的单元格。


如果单元格包含公式列表中的多个值之一,则显示匹配项

有时,您可能要检查一个单元格是否在列表中包含一个值,然后返回该值,如果多个值匹配,则列表中所有匹配的值都将显示,如下图所示。如何在Excel中解决此任务?

如果单元格包含特定文本之一,则要显示所有匹配的值,请应用以下公式:

=TEXTJOIN(", ", TRUE, IF(COUNTIF(A2, "*"&$D$2:$D$7&"*"), $D$2:$D$7, ""))

备注:在以上公式中, D2:D7 是您要基于其检查单元格的特定数据范围,并且 A2 是您要检查的单元格。

然后,按 Ctrl + Shift + Enter 键一起获得第一个结果,然后将填充手柄向下拖动到要应用此公式的单元格,请参见屏幕截图:

提示:

上面的TEXTJOIN函数仅适用于Excel 2019和Office 365,如果您具有早期的Excel版本,则应应用以下公式:

=IFERROR(INDEX($D$2:$D$7, SMALL(IF(COUNTIF($A2, "*"&$D$2:$D$7&"*"), MATCH(ROW($D$2:$D$7), ROW($D$2:$D$7)), ""), COLUMNS($F$1:F1))), "")

备注:在以上公式中, D2:D7 是您要基于其检查单元格的特定数据范围,并且 A2 是您要检查的单元格。

然后,按 Ctrl + Shift + Enter 键在一起以获得第一个结果,然后将公式单元格拖动到右侧直到显示空白单元格,然后继续将填充手柄向下拖动到其他单元格,所有匹配的值都已显示,如下面的屏幕快照所示:


如果单元格包含具有方便功能的列表中的多个值之一,则突出显示匹配项

如果您要突出显示匹配值的特定字体颜色(如果单元格包含另一个列表中的多个值之一),则在本节中,我将介绍一个简单的功能, 标记关键字 of Kutools for Excel,使用此实用程序,您可以一次在单元格中突出显示特定的一个或多个关键字。

请注意:应用这些 标记关键字 功能,首先,您应该下载 Kutools for Excel,然后快速轻松地应用这些功能。

安装后 Kutools for Excel,请执行以下操作:

1。 点击 库工具 > 文本 > 标记关键字,请参见屏幕截图:

2。 在 标记关键字 对话框,请执行以下操作:

  • 从中选择要突出显示匹配文本的数据范围 范围 文本框;
  • 选择包含要突出显示的关键字的单元格,也可以将关键字手动输入(以逗号分隔)。 关键字 文本框
  • 最后,您应指定一种字体颜色以通过选中来突出显示文本 标记关键字颜色 选项。 

3。 然后,点击 Ok 按钮,所有匹配的文本均已突出显示,如下图所示:


更多相关文章:

  • 在Excel中比较两个或多个文本字符串
  • 如果要比较区分大小写或不区分大小写的工作表中的两个或多个文本字符串,如下面的屏幕截图所示,本文将为您介绍一些有用的公式,以供您在Excel中处理此任务。
  • 如果单元格包含文本,则在Excel中显示
  • 现在,如果您在A列中有一个文本字符串列表,并且有一行关键字,则需要检查关键字是否出现在文本字符串中。 如果关键字出现在单元格中,则显示该关键字,否则,将显示空白单元格,如下图所示。
  • 在Excel中查找和替换多个值
  • 通常,“查找和替换”功能可以帮助您查找特定文本并将其替换为另一文本,但是有时,您可能需要同时查找和替换多个值。 例如,将所有“ Excel”文本替换为“ Excel 2019”,将“ Outlook”替换为“ Outlook2019”等,如下图所示。 本文中,我将介绍解决Excel中此任务的公式。

最佳办公生产力工具

🤖 Kutools 人工智能助手:基于以下内容彻底改变数据分析: 智能执行   |  生成代码  |  创建自定义公式  |  分析数据并生成图表  |  调用 Kutools 函数...
热门特色: 查找、突出显示或识别重复项   |  删除空白行   |  合并列或单元格而不丢失数据   |   不使用公式进行四舍五入 ...
超级查询: 多条件VLookup    多值VLookup  |   跨多个工作表的 VLookup   |   模糊查询 ....
高级下拉列表: 快速创建下拉列表   |  依赖下拉列表   |  多选下拉列表 ....
列管理器: 添加特定数量的列  |  移动列  |  切换隐藏列的可见性状态  |  比较范围和列 ...
特色功能: 网格焦点   |  设计图   |   大方程式酒吧    工作簿和工作表管理器   |  资源库 (自动文本)   |  日期选择器   |  合并工作表   |  加密/解密单元格    按列表发送电子邮件   |  超级筛选   |   特殊过滤器 (过滤粗体/斜体/删除线...)...
前 15 个工具集12 文本 工具 (添加文本, 删除字符,...)   |   50+ 图表 类型 (甘特图,...)   |   40+ 实用 公式 (根据生日计算年龄,...)   |   19 插入 工具 (插入二维码, 从路径插入图片,...)   |   12 转化 工具 (小写金额转大写, 货币兑换,...)   |   7 合并与拆分 工具 (高级组合行, 分裂细胞,...)   |   ... 和更多

使用 Kutools for Excel 增强您的 Excel 技能,体验前所未有的效率。 Kutools for Excel 提供了 300 多种高级功能来提高生产力并节省时间。  单击此处获取您最需要的功能...

产品描述


Office Tab 为 Office 带来选项卡式界面,让您的工作更加轻松

  • 在Word,Excel,PowerPoint中启用选项卡式编辑和阅读,发布者,Access,Visio和Project。
  • 在同一窗口的新选项卡中而不是在新窗口中打开并创建多个文档。
  • 每天将您的工作效率提高50%,并减少数百次鼠标单击!
Comments (56)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hello,

I have spreadsheet that have some cell with following test $5655 (BIT001), $4445 (BIT002). I would like to extract every BITxxx and display in another cell with BIT001, BIT002. I'm using MID and FIND but it work only with one BIT001 and BIT002 seems to not search. How would you do it guys?
This comment was minimized by the moderator on the site
You can use text to column > Deliminate > ("("), - I will spit the text from Open Bracket .. like BIT001), then you can remove the closing bracket with a find and replace option.
This comment was minimized by the moderator on the site
Hi all,

Any suggestions...

I have a VALUE next to the SPECIFIC TEXT column F. I need a RESULT in Column B with the VALUE next to SPECIFIC TEXT.
This comment was minimized by the moderator on the site
In option "Display the matches if cell contains one of several values from a list with formulas" I'm having issues in "Result" when the "Specific Text" values is similar to others.

For example, if I have in "Specific Text" the values 'remove' and 'remove lines', I need to get in "Result" the correct value.

Thanks
This comment was minimized by the moderator on the site
I find an option in other webpage:

=TEXTJOIN(" ",1,IF(ISNUMBER(FIND(" "&$F$2:$F$6&" "," "&B2&" ")),$F$2:$F$6,""))
This comment was minimized by the moderator on the site
In the option "Display the matches if cell contains one of several values from a list with formulas" I'm having issues if the word to search is similar to other word. For example if in "Specif text" I have: Remove and Remove line, I need to get/recognise in "Result" the different values ("Remove" for 1 line and "Remove line" in other line). The problem is that always I'm getting "Remove"
This comment was minimized by the moderator on the site
Bonjour, j'essaye cette formule sur une très grande liste de mot et la recherche fait un contient, mais pas au mot entier.
Vous avez une solution ?

Par exemple, le mot de ma liste à rechercher est "aire". Cependant, le mot "horaire" m'indique vrai... avec la formule.
Alors oui "horaire" contient "aire" mais pas en mot entier...

Autre exemple : le mot de ma liste à rechercher est "ri". Cependant, le mot "clé dynamométrique" m'indique vrai...

Merci
This comment was minimized by the moderator on the site
Hello, Greg,
Sorry, I can't understand you clearly.
Could you explain your problem in English? Or you can upload a file or screenshot of your problem here.
Thank you!
This comment was minimized by the moderator on the site
=IF(SUMPRODUCT(--ISNUMBER(SEARCH($D$2:$D$6,A2))),"Yes","No")

Is there a way of amending the formula to return the number of words appear in the text examined?

e.g. returned answer is not whether one of three words (a given list) are found, but if 1, 2, or 3 words are found.

Hope this makes sense................

Thanks



Alan
This comment was minimized by the moderator on the site
Hello, Alan,
To solve your problem, the following array formula may help you: (Note: After inserting the formula, press Ctrl + Shift + Enter keys together to get the first result.)
=SUM((LEN(A2)-LEN(SUBSTITUTE(A2,$D$2:$D$5,"")))/LEN($D$2:$D$5))


Please have a try, hope it can help you!
This comment was minimized by the moderator on the site
help someone. I have a spreadsheet that has example below. I need a formula that will search and return the following based on what is in the cell

A-05-002F: Air Conditioning Unit or Heat Pump Split System - Qtrly Filter
A-11-025: Air Handler Unit - Annual
E-42-001: Emergency Generators - Weekly #4

The above is in C2 I want E2 to display Q if cell contains Qtrly, A if cell contains Annual, W if cell contains weekly
This comment was minimized by the moderator on the site
Hi, Lynda,
To solve your problem, please apply the following formula:
=IF(ISERROR(SEARCH("Qtrly",C2)),IF(ISERROR(SEARCH("Annual",C2)),IF(ISERROR(SEARCH("weekly",C2)),"","W"),"A"), "Q")

Please have a try, hope it can help you!
This comment was minimized by the moderator on the site
Correction the above information is in C2 C3 C4
This comment was minimized by the moderator on the site
RE: above example  =IFERROR(INDEX($D$2:$D$7, SMALL(IF(COUNTIF($A2, "*"&$D$2:$D$7&"*"), MATCH(ROW($D$2:$D$7), ROW($D$2:$D$7)), ""), COLUMNS($F$1:F1))), "")I keep error with Excel 2010.  Same with example for Excel 2019, in Excel 2019 on a different PC. Tried the one  Is it Wish it was available in my Kutools  
This comment was minimized by the moderator on the site
Multiple search value in a single cell, and return as a Common Value
This comment was minimized by the moderator on the site
Is it possible to do this with a partial match of the keywords? This method is only an exact match
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations