简体   繁体   中英

How to highlight all instances of a cell value in a column based on another cell in same row?

I am trying to use either CONDITIONAL FORMATTING or VBA to achieve the following.

Let's assume columns A and B
Column A contains a list of locations and are duplicated many times, eg. the location "ANYWHERE" could be in 20 different rows (but in the same column).
Column B contains a Vlookup code that results in a numerical value (including 0) or are blank.

I want IF column B contains a value that is NOT 0 to highlight ALL INSTANCES of the same location in column A (even if the value is blank or 0 in column B).

So if on row 300, there is a location 'ANYWHERE' and column B (for that row) has a value of '10' then highlight EVERY instance of the word "ANYWHERE" in column A (below and above).

I got halfway there with conditional formatting to highlight the value in column A for any value that is not blank or higher than 0 in column B, but I do not know how to highlight all instances of that value in column A.

Also, if in row 100, 'ANYWHERE' has a value of '20' in column B (and thus all instances of "ANYWHERE" get highlighted, and then in row 200 'ANYWHERE' has no value in column B, that instance of 'ANYWHERE' should NOT get UN-highlighted

The values in the first column should be highlighted based on the value in the last column.
In this case, everything with NM-5F-0335 should be highlighted
在此处输入图像描述

Here is the formula: =COUNTIFS($A$1:$A$12,$A1,$B$1:$B$12,"<>0")>0

Screenshot for example:

在此处输入图像描述

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