简体   繁体   English

如果单元格包含特定文本,则突出显示整行

[英]Highlighting entire row if cell contains specific text

I require to highlight an entire row in Excel if a cell string contains the word "site" in column G. I am using conditional formatting with a formula which uses the following formula which doesn't work. 如果单元格字符串在G列中包含单词“ site”,则需要在Excel中突出显示整行。我正在使用条件格式设置公式,该公式使用的以下公式无效。

=INDIRECT("g"&ROW())=MID("g"&ROW(),FIND("site","g"&ROW(),1),4)

On a side note: the following works perfectly but only for exact matches where the content of the cell ONLY contains "site" as string: 顺便说一句:以下内容非常有效,但仅适用于完全匹配的情况,其中单元格的内容仅包含“ site”作为字符串:

=INDIRECT("g"&ROW())="site"

You don't need to use INDIRECT of MID , if you can use some lock mechanisms: 如果可以使用一些锁定机制,则无需使用INDIRECT MID

=FIND("site",$G1)>0

在此处输入图片说明

Here, you will see the active cell is A1, so the corresponding row Excel will compare it to will be G1, when conditional formatting looks at cell A2, it will compare it to G2. 在这里,您将看到活动单元格为A1,因此相应的行Excel会将其与G1进行比较,当条件格式查看单元格A2时,它将与G2进行比较。

When the conditional formatting looks at cell B2, it will compare it to G2 again because G was locked (via the $ symbol). 当条件格式查看单元格B2时,由于G被锁定(通过$符号),它将再次将其与G2比较。


That said, your formula was not working because FIND("site","g"&ROW(),1) fails. 就是说,您的公式无效,因为FIND("site","g"&ROW(),1)失败。 The second argument gives the text g# (where # represents the row number) and the search fails). 第二个参数给出文本g# (其中#代表行号),搜索失败。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM