Home » excel » excel – Highlight Cells Based on If Function

excel – Highlight Cells Based on If Function

Posted by: admin May 14, 2020 Leave a comment

Questions:

Is there a VBA code or excel function which can highlight the A cell based on the value of the corresponding B cell. For example if the number in row A is larger than B then highlight the A cell green and orange if B is larger. As shown

enter image description here

Is there some option to do this in conditional formatting? Or even a VBA code?

How to&Answers:

Add something like this using conditional formatting:

Demo

^ =A1<A2 and =A1>A2.

And then select the Format Painter and drag it along:

Demo2

Answer:

No need manual formatting. Just use full range containing data in Apply To section.

As per your screenshot.

  1. Select B1:G2 cells.
  2. Select Conditional Formatting under style section. Then click on New Rule.
    enter image description here

  3. Select Use a formula to determine which cells to format.

enter image description here

  1. Use formula like below screenshot.

    =B1<B$2

    =B1>B$2

enter image description here

Result

enter image description here