Forum Discussion

Antoniou_Thanasis's avatar
Antoniou_Thanasis
Copper Contributor
Feb 21, 2023
Solved

Auto Adjust cell color, if previous cell is bigger or smaller number.

Hello, 

 

I want to add colours on the table below automaticaly. I know how to do it using conditional formating. I would like to know if it is possible for the cell to get a color automatically when I enter new numbers in the table. I would like the function to calculate the previous cell and not with a predefined value. For example, if in the 6th column, first row, I enter the number 36, the color will turn green, while if I enter 38, it will turn red, because the previous value is 37.

 

 

  • HansVogelaar's avatar
    HansVogelaar
    Feb 21, 2023

    Thanasis_Antoniou 

    Select the cells that you want to format. In the following, I will assume that C3 is the top left cell of the selection, and that it is the active cell in the selection.

     

    On the Home tab of the ribbon, click Conditional Formatting > New Rule...
    Select 'Use a formula to determine which cells to format'.
    Enter the formula

     

    =NOT(AND(ISNUMBER(B3),C3>B3))

     

    Remember, C3 is the active cell, and B3 is the cell to the left of that.

    Click Format...
    Activate the Fill tab.
    Select Green.

     

    Repeat these steps, but with the formula

     

    =AND(ISNUMBER(B3),C3>B3)

     

    and Red.
    Click OK, then click OK again.

    • Thanasis_Antoniou's avatar
      Thanasis_Antoniou
      Copper Contributor
      it is just text value -. i can leave it empty if it helps. I just dont value for those cells.
      • HansVogelaar's avatar
        HansVogelaar
        MVP

        Thanasis_Antoniou 

        Select the cells that you want to format. In the following, I will assume that C3 is the top left cell of the selection, and that it is the active cell in the selection.

         

        On the Home tab of the ribbon, click Conditional Formatting > New Rule...
        Select 'Use a formula to determine which cells to format'.
        Enter the formula

         

        =NOT(AND(ISNUMBER(B3),C3>B3))

         

        Remember, C3 is the active cell, and B3 is the cell to the left of that.

        Click Format...
        Activate the Fill tab.
        Select Green.

         

        Repeat these steps, but with the formula

         

        =AND(ISNUMBER(B3),C3>B3)

         

        and Red.
        Click OK, then click OK again.

Resources