Forum Discussion

Rogerswrightonerogers's avatar
Rogerswrightonerogers
Copper Contributor
Jul 20, 2022

How to change a cell fill color when number value is changed in Excel?

Price list is pre-filled with product and cost. However, client may change the cost if needed. 
Looking for formula/formatting so that when cost is changed, the cell fill color changes to alert of change.  CONDITIONAL FORMATTING did not work.
Sample list 

 

 


  • Rogerswrightonerogers 

    Maybe with the Worksheet_Change event. In the attached file you can change the product cost in any of the cells in range D2:D20 and the cell is highlighted.

    Private Sub Worksheet_Change(ByVal Target As Range)
    
    If Target.Cells.Count > 1 Then GoTo done
    
    If Application.Intersect(Target, ActiveSheet.Range("D2:D20")) Is Nothing Then GoTo done
    
    Application.EnableEvents = False
    
    Target.Interior.ColorIndex = 6
    
    done:
    Application.EnableEvents = True
    Exit Sub
    
    End Sub

     

Resources