graemeal
Active Member
- Joined
- May 17, 2007
- Messages
- 316
- Platform
- Windows
Hi, the below code makes cell A1 and A2 flash either red or green depending on if the number in it become greater or less. Green for increase and red for decrease.
I would like to add more cells, as in a range. Preferably B5:B9 and C5:B9. If that is too difficult maybe B3:B12
Thank you kindly
Windows 7 - Excel 2007
In Standard Module.
In Sheet Module
I would like to add more cells, as in a range. Preferably B5:B9 and C5:B9. If that is too difficult maybe B3:B12
Thank you kindly
Windows 7 - Excel 2007
In Standard Module.
Code:
Public a1n2(1) As Variant
Public t As Range
Public Sub revintcol()
t.Interior.ColorIndex = -4142
Set t = Nothing
End Sub
In Sheet Module
Code:
Private Sub Worksheet_Calculate()
If Cells(1, 1) > a1n2(0) Then
Cells(1, 1).Interior.Color = vbGreen
ElseIf Cells(1, 1) < a1n2(0) Then Cells(1, 1).Interior.Color = vbRed
ElseIf Cells(2, 1) > a1n2(1) Then Cells(2, 1).Interior.Color = vbGreen
ElseIf Cells(2, 1) < a1n2(1) Then Cells(2, 1).Interior.Color = vbRed
End If
a1n2(0) = Cells(1, 1)
a1n2(1) = Cells(2, 1)
st = Timer + 0.2
Do Until Timer > st
Loop
Range("A1:A2").Interior.ColorIndex = -4142
End Sub