[英]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.