Celia - HELP! Re: Flash SubProgram


Posted by Frank H. on February 19, 2001 2:17 PM

Celia (or anyone with an answer),

I have been using the Flash SubProgram you posted in response to a question on 01/19/2001. It works just great! However, I now want to use it to "flash" the background of a cell when the formula in a cell returns a negative number (i.e. -7.25). I have been unable to properly write the code or find any additional information on in the many books I have or on the web. (Note - I am just started writing VBA code)

Can you help? (See line of code with *** above & below it.)

Thanks you

Dim RunWhen As Double
Dim toFlash As Range
Sub StartFlash()
Dim cell As Range, grades As Range
Dim x%, grade1$
Set grades = Range("C7")

***********************************************
grade1 = ???? (need to identify a negative number)
***********************************************

On Error Resume Next
Application.OnTime RunWhen, "FlashText", , False
grades.Interior.ColorIndex = xlNone
For Each cell In grades
If cell.Value = grade1 Or cell.Value = grade2 Then
If x = 1 Then
Set toFlash = Union(toFlash, cell)
Else:
Set toFlash = cell
x = 1
End If
End If
Next
If x = 0 Then
MsgBox "You are within your guidelines."
Exit Sub
End If
RunWhen = Now + TimeSerial(0, 0, 1)
Application.OnTime RunWhen, "FlashText"
End Sub
Sub FlashText()
With toFlash.Interior
If .ColorIndex = xlNone Then
.ColorIndex = 3
Else: .ColorIndex = xlNone
End If
End With
RunWhen = Now + TimeSerial(0, 0, 1)
Application.OnTime RunWhen, "FlashText"
End Sub
Sub StopFlash()
On Error Resume Next
Application.OnTime RunWhen, "FlashText", , False
toFlash.Interior.ColorIndex = xlNone
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call StopFlash
End Sub



Posted by Celia on February 19, 2001 4:06 PM


Frank

Dim RunWhen As Double
Dim toFlash As Range
Sub StartFlash()
Dim cell As Range, grades As Range
Dim x%
Set grades = Range("C7")

On Error Resume Next
Application.OnTime RunWhen, "FlashText", , False
grades.Interior.ColorIndex = xlNone
For Each cell In grades
If cell.Value < 0 Then
If x = 1 Then
Set toFlash = Union(toFlash, cell)
Else:
Set toFlash = cell
x = 1
End If
End If
Next
If x = 0 Then
MsgBox "You are within your guidelines."
Exit Sub
End If
RunWhen = Now + TimeSerial(0, 0, 1)
Application.OnTime RunWhen, "FlashText"
End Sub
Sub FlashText()
With toFlash.Interior
If .ColorIndex = xlNone Then
.ColorIndex = 3
Else: .ColorIndex = xlNone
End If
End With
RunWhen = Now + TimeSerial(0, 0, 1)
Application.OnTime RunWhen, "FlashText"
End Sub
Sub StopFlash()
On Error Resume Next
Application.OnTime RunWhen, "FlashText", , False
toFlash.Interior.ColorIndex = xlNone
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call StopFlash
End Sub

Celia