简体   繁体   English

突出显示另一个单元格中包含值的所有单元格

[英]Highlight all cells that contain a value in another cell

I am using Excel 我正在使用Excel

I would like to hihglight every cell in a spreadsheet that contains (Case-Insensitive) the value entered in another cell. 我想高亮显示包含(不区分大小写)在另一个单元格中输入的值的电子表格中的每个单元格。

I have been playing around with conditional formating but I have not found success. 我一直在研究条件格式,但没有找到成功。

This small macro uses the value found in cell A1 and hi-lights any cell containing that value: 这个小宏使用单元格A1中的值,并高亮显示包含该值的任何单元格:

Sub ColorCells()
    Dim s As String, r As Range
    s = Range("A1").Text
    For Each r In ActiveSheet.UsedRange
        If InStr(1, r.Text, s) > 0 Then
            r.Interior.ColorIndex = 27
        End If
    Next r
End Sub

For example: 例如:

在此处输入图片说明

Excel treats a 0 ( zero ) as FALSE. Excel将0 )视为FALSE。 By strict definition, anything that is not FALSE is TRUE. 根据严格的定义,任何非FALSE的都是TRUE。 Conditional formatting rules based upon a formula are only looking for a TRUE or FALSE; 基于公式的条件格式设置规则仅在查找TRUE或FALSE。 anything more than that is superfluous. 仅此而已是多余的。 The formula you described in the comments section of your original question could be pared down to, 您在原始问题的注释部分中描述的公式可以简化为:

=COUNTIF(A4,"*" & $A$2 & "*")

Another method for case insensitive search is to see if SEARCH returns a position (eg it was found) or an error (eg it was not found). 不区分大小写搜索的另一种方法是查看SEARCH返回位置(例如,找到了)或错误(例如,没有找到)。

=ISNUMBER(SEARCH($A$2, A4))

This can optionally be turned into a case-sensitive search by swapping out SEARCH for FIND . 通过将SEARCH换为FIND可以选择将其转换为区分大小写的搜索。

=ISNUMBER(FIND($A$2, A4))

暂无
暂无

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

相关问题 如何检查单元格是否包含多个值之一,如果这些列都包含任一值,则如何更改另一个单元格 - How can I check if cells contain one of several values and change another cell if those columns all contain either value 从另一个单元格值中突出显示单元格(动态范围) - Highlight cell from another cells value (dyanmic range) 当单元格的总和达到 Excel 中另一个单元格的值时突出显示单元格 - Highlight cells when its sum reached the value on another cell in Excel 如何根据另一个像元值​​VBA突出显示一个像元? - How to highlight a cell based on another cells value VBA? Excel宏突出显示与当前单元格中的值匹配的所有单元格 - Excel macro to highlight all cells that match value in current cell 根据另一列中单元格的值突出显示单元格 - Highlight cells based on the value of cells in another column 如何突出显示两个Excel单元格,每个单元格中包含多个单词 - How to highlight two excel cells contain multiple words in each cell 如何基于同一行中的另一个单元格突出显示列中单元格值的所有实例? - How to highlight all instances of a cell value in a column based on another cell in same row? 如何根据另一个单元格值突出显示单元格值 - how to Highlight cells value based on another cells value 将一列中所有单元格的值添加到另一列中的相应单元格,然后清除原始单元格 - Add value in all cells within a column to corresponding cell in another column and then clear original cells
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM