跳到主要內容

如何檢查單元格是否包含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 Excel的Kutools,使用此實用程序,您可以一次在單元格中突出顯示特定的一個或多個關鍵字。

注意:應用這些 標記關鍵字 功能,首先,您應該下載 Excel的Kutools,然後快速輕鬆地應用這些功能。

安裝後 Excel的Kutools,請執行以下操作:

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選項卡為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