PDA

View Full Version : Modifying Code for Whole to Flash



Panda
03-28-2011, 07:05 AM
Hi All,

I have found some code online to highlight a cell when it contains the grade F inside and make it flash, however can this be modifed to that the entire row is highlighted and flashes instead?




Option Explicit
Dim RunWhen As Double
Dim toFlash As Range
Sub StartFlash()
Dim cell As Range, grades As Range
Dim x%, theGrade$
Set grades = Range("A1:H20")
theGrade = "F"
grades.Interior.ColorIndex = xlColorIndexAutomatic
For Each cell In grades
If cell.Value = theGrade Then
If x = 0 Then
Set toFlash = cell
x = 1
Else: Set toFlash = Union(toFlash, cell)
End If
End If
Next
RunWhen = Now + TimeSerial(0, 0, 1)
Application.OnTime RunWhen, "FlashText"
End Sub
Sub FlashText()
With toFlash.Interior
If .ColorIndex = xlColorIndexAutomatic Then
.ColorIndex = 3
Else
.ColorIndex = xlColorIndexAutomatic
End If
End With
RunWhen = Now + TimeSerial(0, 0, 1)
Application.OnTime RunWhen, "FlashText"
End Sub
Sub StopFlash()
Application.OnTime RunWhen, "FlashText", , False
End Sub



Thanks in advance

Phil

Panda
03-28-2011, 07:14 AM
Its OK I managed to solve it by simply adding "Cell.EntireRow" =:)