简体   繁体   中英

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.

=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:

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

You don't need to use INDIRECT of MID , if you can use some lock mechanisms:

=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.

When the conditional formatting looks at cell B2, it will compare it to G2 again because G was locked (via the $ symbol).


That said, your formula was not working because FIND("site","g"&ROW(),1) fails. The second argument gives the text g# (where # represents the row number) and the search fails).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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