Assuming the range that may contain D or F is A1:A20, add the following line at the end of your macro :-
Call StartFlash
and add the following procedures to your workbook :-
Dim RunWhen As Double
Dim toFlash As Range
Sub StartFlash()
Dim cell As Range, grades As Range
Dim x%, grade1$, grade2$
Set grades = Range("A1:A20")
grade1 = "D"
grade2 = "F"
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 "There are no " & grade1 & _
" & " & grade2 & " grades."
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
Celia; I now need the font to blink instead of the background. I'm having problems with this, can you help??? Would it be of any help if I was to send this document to you? Thank you so much
Wes
I think the following does it :-
Dim RunWhen As Double
Dim toFlash As Range
Sub StartFlash()
Dim cell As Range, grades As Range
Dim x%, theGrade$
Set grades = Range("A1:A20")
theGrade = "F"
On Error Resume Next
Application.OnTime RunWhen, "FlashText", , False
grades.Font.ColorIndex = xlAutomatic
For Each cell In grades
If cell.Value = theGrade 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 "There are no " & theGrade & " grades."
Exit Sub
End If
RunWhen = Now + TimeSerial(0, 0, 1)
Application.OnTime RunWhen, "FlashText"
End Sub
Sub FlashText()
With toFlash.Font
If .ColorIndex = xlAutomatic Then
.ColorIndex = 3
Else: .ColorIndex = xlAutomatic
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.Font.ColorIndex = xlAutomatic
End Sub
Celia