简体   繁体   中英

Formatting cell based on adjacent cell value

I would like a cell to be color filled or formatted based on the value in the adjacent cell. For example, if cell D1= #NA then I want the font in C1 to be filled in red.I would like to compare entire range in column C and D for this. Is there any conditional formatting rules or VBA macro that can accomplish this?

Very simply select the range you want in column C and just make a conditional format using an equation and use

=$D1=""

and change the format text color to what ever you want.

Conditional formatting would be easiest way to do this.

If under conditional formatting you select new rule and then "use a formula to determine which cells to format". A formula such as =$D$1="#na" and change the format to what you would like. If you click OK and make sure this applies to C1 and stop if true is selected.

This worked for me! If you would like to use vba then let me know.

To apply such a format to C3 based on the contents of D3:

  1. Select C3
  2. In Conditional Formatting click New Rule...
  3. Select "Use a formula to determine which cells to format"
  4. For the formula enter "=ISNA($D$3)"
  5. Click the Format button to set up the format that gets applied when the previous formula returns TRUE

Hope that helps

Conditional Formatting can do this. Pick the "Use a formula to determine which cells to format", enter

=7=ERROR.TYPE(D1)

Set the red fill. Now copy & apply to entire column.

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