As John Bustos said, you need another column that houses the previous value
of the cell. This value is necessary in order to do comparison to discern if the target is now higher or lower.
In order to achieve a flash, you need to set a pause in the code without freezing up the main UI. This code isn't tested or guaranteed to work as you want, but it should serve as a very good starting point.
CODE
Private Sub Worksheet_Change(ByVal Target As Range)
Dim KeyCells As Range
Set KeyCells = Range("B1:B27")
If Not Application.Intersect(KeyCells, Range(Target.Address)) _
Is Nothing Then
If Target.Value > Cells(Target.Row, 5).Value Then
'flash green
Target.Interior.ColorIndex = 10
Pause 0.5
Target.Interior.ColorIndex = 2
Pause 0.5
Target.Interior.ColorIndex = 10
ElseIf Target.Value < Cells(Target.Row, 5).Value Then
'flash red
Target.Interior.ColorIndex = 3
Pause 0.5
Target.Interior.ColorIndex = 2
Pause 0.5
Target.Interior.ColorIndex = 3
End If
Cells(Target.Row, 5).Value = Target.Value
End If
End Sub
'Pauses execution without holding up main UI thread
Public Function Pause(NumberOfSeconds As Variant)
On Error GoTo Error_GoTo
Dim PauseTime As Variant
Dim Start As Variant
PauseTime = NumberOfSeconds
Start = Timer
Do While Timer < Start + PauseTime
DoEvents
Loop
Exit_GoTo:
On Error GoTo 0
Exit Function
Error_GoTo:
Debug.Print Err.Number, Err.Description, Erl
GoTo Exit_GoTo
End Function
Open the Visual Basic Editor (VBE) and double click Sheet 1, then paste the above code. Now you'll notice as you change the values within the targeted range B1:B27
a value with be placed in column E
. You can change this in the code above by replacing 5
in Cells(Target.Row, 5).Value
with whatever column you'd like.
Now as the values increase or decrease, the cell will flash to reflect the change.
The Pause
function was found on this SO Post.