Color coding a cell based on the contents of a different cell

Dee Cee 20 Reputation points
2025-03-18T23:40:59.6566667+00:00

User's image

Microsoft 365 and Office | Excel | For business | Windows
{count} votes

2 answers

Sort by: Most helpful
  1. Emi Zhang-MSFT 30,046 Reputation points Microsoft External Staff
    2025-03-19T03:04:46.4466667+00:00

    Hi.

    Can you provide the range of conditions corresponding to different colors?

    I created a sample about your requirement:

    Red color: =0 Out of stock

    Yellow color: >=1, <=400 Low inventory

    Green color: >400 Healthy

    1. Select the range C2:C10, go to Home- Conditional Formatting- select New Rule...
      User's image
    2. Select Use a formula to determine which cells to format- then enter the formula for different color and set the cell formatting: Red: =B2=0
      Yellow: =AND(B2>=1,B2<=400) Green: =B2>400
      User's image User's image User's image User's image
    3. Then enter the formula in cells:
      =IF(B2=0,"Out of stock",IF(AND(B2>=1,B2<=400),"Low inventory",IF(B2>400,"Healthy","")))
      User's image

    Hope the steps will help.


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Barry Schwarz 3,746 Reputation points
    2025-03-20T07:34:31.4666667+00:00

    If I understand correctly, the colors in column D on sheet 2 are thee just so we know what colors you want to see in column B on sheet1. The values in sheet 2, including the status in column D come from the report. You want the colors in column B on sheet 1 to provide a quick indication of the status on sheet2.

    In your sample data, each stock code on sheet 1 is in the same row as that value on sheet 2. In that case, the following conditional formatting formula applied to sheet 1 column B will allow you to assign a green fill those stock codes that the report marked healthy in sheet 2:

    =INDIRECT(ADDRESS(ROW(),4,,,"sheet2"))="Healthy"

    Creating two additional formulas, each with an appropriate quoted status, will let you assign the red and orange fills in the same way.

    If the stock codes are not in the same rows on the two sheets, the first argument of the ADDRESS function becomes a little more complex but the concept is the same.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.