1. #1
    Justin7
    Justin7's Avatar Become A Pro!
    Join Date: 07-31-06
    Posts: 8,577
    Betpoints: 1506

    Excel color question

    Is there a way to change a cell to a specific color, based on an if statement?

    For example, Cell A1 will be 0 or 1. If it is a 1, I want cell A2 to turn from normal to Orange.

  2. #2
    crjohnson32
    crjohnson32's Avatar Become A Pro!
    Join Date: 12-16-10
    Posts: 989
    Betpoints: 237

    look up "conditional formatting" in the help screen

  3. #3
    crjohnson32
    crjohnson32's Avatar Become A Pro!
    Join Date: 12-16-10
    Posts: 989
    Betpoints: 237

    If that helps, a kind word towards getting my pm's restored during the next skype meeting would be greatly appreciated!

  4. #4
    ProfaneReality
    ProfaneReality's Avatar Become A Pro!
    Join Date: 04-14-09
    Posts: 7,607

    yeah goto conditional formatting then to color scales

  5. #5
    brad89
    brad89's Avatar Become A Pro!
    Join Date: 06-19-10
    Posts: 424

    I don't know if you can set up color scales to work with custom IF statements but they will work for your example (-1=red, 0=orange, 1=green)

    I'm not sure if there is any easier way but the way I have it set up is.....

    In C1 I have (you can change/add to this depending on what you actually want)
    Code:
    =IF(A1=-1, "Red", IF(A1=0, "Yellow", IF(A1=1, "Green")))
    Then select column A and go to: Conditional formatting > manage rules > New rule

    Then set up three rules as follows:

    Code:
    =C1 = "Green"
    Click format > Fill > Select green

    Repeat for each one. Once you have done that you can hide column C if you like...

    Hopefully that makes sense, if not I can email you a basic template and you can can see how it is set up.

  6. #6
    allin1
    Update your status
    allin1's Avatar Become A Pro!
    Join Date: 11-07-11
    Posts: 4,555

    interesting stuff about excel formatting http://www.contextures.com/xlcondformat03.html

  7. #7
    allin1
    Update your status
    allin1's Avatar Become A Pro!
    Join Date: 11-07-11
    Posts: 4,555

    Quote Originally Posted by Justin7 View Post
    Is there a way to change a cell to a specific color, based on an if statement?

    For example, Cell A1 will be 0 or 1. If it is a 1, I want cell A2 to turn from normal to Orange.
    I have office 2007.

    In excel you can use conditional formatting to change the color of a cell depending on it's value.

    For example if A1 =1 -> color changes.
    This can be easily done selecting the cell->go to conditional formatting->new rule->format only cells that contain->
    select cell value->equal to->1->click on format tab and select different color. You can change the color of the text or the color of the fill.

    conditional formatting.jpg conditional formatting 2.jpg

    conditional formatting 4.jpg conditional formatting 5.JPG conditional formatting 6.JPG

    You can also use the data bar option if you like the style

    conditional formatting 3.JPG

    I don't know if/how you can do it for different cells though, for example if A1=1 then A2 changes color, but I will get back with a post if I find out how.
    Last edited by allin1; 11-14-11 at 05:26 AM.

  8. #8
    allin1
    Update your status
    allin1's Avatar Become A Pro!
    Join Date: 11-07-11
    Posts: 4,555

    Quote Originally Posted by Justin7 View Post
    Is there a way to change a cell to a specific color, based on an if statement?

    For example, Cell A1 will be 0 or 1. If it is a 1, I want cell A2 to turn from normal to Orange.
    Quote Originally Posted by allin1 View Post

    I have office 2007.

    In excel you can use conditional formatting to change the color of a cell depending on it's value.

    For example if A1 =1 -> color changes.

    I don't know if/how you can do it for different cells though, for example if A1=1 then A2 changes color, but I will get back with a post if I find out how.
    I figured it out how you can do it.

    You select the cell A2, click "conditional formatting"-> select "new rule"->select "use formula to determine which cells to format"->
    enter the fomula: =$A1=1 , then click "format"-> select "fill" tab-> chose color.

    for justin.jpg

    for justin 2.JPG

    for justin 3.JPG

    This conditional formatting seems quite useful. I found the formula by trial and error but my guess is that you can use all sorts of conditions like: if number in cell X is bigger than the number in cell Y then change the color or the value of cell Z.
    Last edited by allin1; 11-14-11 at 05:33 AM.

Top