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