简体   繁体   English

如何突出显示两个Excel单元格,每个单元格中包含多个单词

[英]How to highlight two excel cells contain multiple words in each cell

this may be a bit difficult to explain but i will use the example below 这可能有点难以解释,但我将使用以下示例

在此处输入图片说明

as you can see, the excel sheet has two columns (C and F) I was able to use conditional formatting to highlight the duplicate cells with the green color. 如您所见,excel工作表有两列(C和F),我能够使用条件格式来突出显示绿色的重复单元格。 I would like to know how to also two different cells that contain multiple words with at-least one word in each cell being the same, as you can see the cells with the yellow color. 我想知道如何将包含多个单词的两个不同单元格的每个单元格至少保留一个单词,因为您可以看到黄色的单元格。 thanks 谢谢

You can use a UDF below to compare the values 您可以使用下面的UDF比较值

Public Function comparecells(cell1 As String, cell2 As String) As Boolean

'store words of each cells in two diffrent arrays

    array1 = Split(cell1, " ")
    array2 = Split(cell2, " ")

    'reset the function value
    comparecells = False

    'check each word from one array against the other
    For Each Value1 In array1
        For Each Value2 In array2
            If Value1 = Value2 Then
                'If it finds any match set function return value to true and exit
                comparecells = True
                Exit Function
            End If
        Next Value2
    Next Value1

End Function

Here's a formula for conditional formatting which will return TRUE if at least a word matches. 这是条件格式的公式,如果至少一个单词匹配,它将返回TRUE。

This is written for cell C2 and it is assumed that it is looking for values in cells F2 to F15. 这是为单元格C2写的,并且假定它正在寻找单元格F2至F15中的值。

=NOT(ISERROR(LOOKUP(2^15,SEARCH(TRIM(MID(SUBSTITUTE(" "&C2," ",REPT(" ",99)),{1,2,3}*99,99)),F2:F15,1),F2:F15)))

Adjust it to suit. 调整使其适合。

暂无
暂无

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

相关问题 如何使用宏在excel中搜索并突出显示单元格内的多个单词? - How to search and highlight multiple words inside cells in excel using macros? 如何删除Excel文档中每一列中特殊字符之后的所有内容,并将两个单词从一个单元格划分为两个单独的单元格? - How to delete everything after special charcter in each column in Excel document and divide two words from one cell to two separate cells? 突出显示包含扩展列表中单词的单元格 - Highlight Cells That Contain Words From an Expanding List Excel:公式搜索包含多个单词的单元格中的单个单词 - Excel: Formula search for individual word in cells that contain multiple words 在所选单元格的每个单元格中突出显示唯一的单词列表 - Excel VBA - Highlighting Unique List of Words in Each Cell of a Selection of Cells - Excel VBA Excel VBA高亮显示范围内不包含单词列表中文本的单元格 - Excel VBA Highlight Cells in Range that Do Not Contain Text from a List of Words 突出显示另一个单元格中包含值的所有单元格 - Highlight all cells that contain a value in another cell VBA/Excel - 计算每个单元格中有多个单词的列中的唯一单词 - VBA/Excel - Count unique words in columns with multiple words in each cell 如何在Excel中突出显示单元格? - How to Highlight Cells in Excel? Excel公式将单元格可能包含多个值的列拆分为另一列,其中每个单元格仅包含一个值 - Excel Formula to split columns where cells may contain multiple values into another column, where each cell only contains a single value
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM