PDA

View Full Version : Solved: Limit Blinking Text To 30 Seconds



zoom38
02-05-2008, 08:07 PM
Hello all,
I have the following blink procedure. I would like to limit the blinking to a set amount of time, say 30 seconds. How do I call "StopBlink" 30 seconds after "StartBlink" begins? Does anyone know how I might do that?



Sub StartBlink()
Dim r As Integer
Dim x As Long

sheets(3).Select
LastRow = Cells(Rows.Count, 1).End(xlUp).Row
r = 3
For x = 3 To LastRow
If Cells(r, 15).Value = "1st Prize" Then
If Cells(r, 15).Font.ColorIndex = 2 Then
Cells(r, 15).Font.ColorIndex = xlColorIndexAutomatic
ElseIf Cells(r, 15).Font.ColorIndex = xlAutomatic Then
Cells(r, 15).Font.ColorIndex = 2
End If
ElseIf Cells(r, 15).Value = "2nd Prize" Then
If Cells(r, 15).Font.ColorIndex = 2 Then
Cells(r, 15).Font.ColorIndex = xlColorIndexAutomatic
ElseIf Cells(r, 15).Font.ColorIndex = xlAutomatic Then
Cells(r, 15).Font.ColorIndex = 2
End If
ElseIf Cells(r, 15).Value = "3rd Prize" Then
If Cells(r, 15).Font.ColorIndex = 2 Then
Cells(r, 15).Font.ColorIndex = xlColorIndexAutomatic
ElseIf Cells(r, 15).Font.ColorIndex = xlAutomatic Then
Cells(r, 15).Font.ColorIndex = 2
End If
ElseIf Cells(r, 15).Value = "4th Prize" Then
If Cells(r, 15).Font.ColorIndex = 2 Then
Cells(r, 15).Font.ColorIndex = xlColorIndexAutomatic
ElseIf Cells(r, 15).Font.ColorIndex = xlAutomatic Then
Cells(r, 15).Font.ColorIndex = 2
End If
ElseIf Cells(r, 15).Value = "5th Prize" Then
If Cells(r, 15).Font.ColorIndex = 2 Then
Cells(r, 15).Font.ColorIndex = xlColorIndexAutomatic
ElseIf Cells(r, 15).Font.ColorIndex = xlAutomatic Then
Cells(r, 15).Font.ColorIndex = 2
End If
ElseIf Cells(r, 15).Value = "6th Prize" Then
If Cells(r, 15).Font.ColorIndex = 2 Then
Cells(r, 15).Font.ColorIndex = xlColorIndexAutomatic
ElseIf Cells(r, 15).Font.ColorIndex = xlAutomatic Then
Cells(r, 15).Font.ColorIndex = 2
End If
ElseIf Cells(r, 15).Value = "7th Prize" Then
If Cells(r, 15).Font.ColorIndex = 2 Then
Cells(r, 15).Font.ColorIndex = xlColorIndexAutomatic
ElseIf Cells(r, 15).Font.ColorIndex = xlAutomatic Then
Cells(r, 15).Font.ColorIndex = 2
End If
ElseIf Cells(r, 15).Value = "8th Prize" Then
If Cells(r, 15).Font.ColorIndex = 2 Then
Cells(r, 15).Font.ColorIndex = xlColorIndexAutomatic
ElseIf Cells(r, 15).Font.ColorIndex = xlAutomatic Then
Cells(r, 15).Font.ColorIndex = 2
End If
ElseIf Cells(r, 15).Value = "9th Prize" Then
If Cells(r, 15).Font.ColorIndex = 2 Then
Cells(r, 15).Font.ColorIndex = xlColorIndexAutomatic
ElseIf Cells(r, 15).Font.ColorIndex = xlAutomatic Then
Cells(r, 15).Font.ColorIndex = 2
End If
End If
r = r + 1
Next x
RunWhen = Now + TimeSerial(0, 0, 1)
Application.OnTime RunWhen, "StartBlink", , True
End Sub




Sub StopBlink()
sheets(3).Range("O3:O" & LastRow).Font.ColorIndex = _
xlColorIndexAutomatic
Application.OnTime RunWhen, "StartBlink", , False '
End Sub



Thanks
Gary

mikerickson
02-05-2008, 09:04 PM
Sub StartBlink()
Dim r As Integer
Dim x As Long

Static blinkCount as Integer
blinkCount = blinkCount +1
If 30 <= blinkCount Then Call StopBlink : blinkCount = 0 : Exit Sub


Rem more Code

End Sub

zoom38
02-05-2008, 10:48 PM
Thanks Mike. I receved an error when StopBlink was called so I just used Exit Sub which works fine.


Static blinkCount As Integer
blinkCount = blinkCount + 1
If blinkCount > 30 Then blinkCount = 1
If blinkCount = 30 Then Exit Sub



Thanks Again
Gary

mikerickson
02-05-2008, 11:10 PM
You're welcome.