• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Blinking Cell

sambit

Member
Hi,
The below code is used for blinking cell. while I try to protect sheet by using password. system generate error message i.e, Run time error '1004' : Application-defined or object-defined error when I debug code i.e, Range(FR).Interior.ColorIndex = xlColorIndexNone is highlight. plz help to resolve the issue.


Public NextFlash As Double
Public Const FR As String = "Sheet1!K18"
Sub StartFlashing()
If Range(FR).Interior.ColorIndex = 3 Then
Range(FR).Interior.ColorIndex = xlColorIndexNone
Else
Range(FR).Interior.ColorIndex = 3
End If
NextFlash = Now + TimeSerial(0, 0, 1)
Application.OnTime NextFlash, "StartFlashing", , True
End Sub
Sub StopFlashing()
Range(FR).Interior.ColorIndex = xlColorIndexNone
Application.OnTime NextFlash, "StartFlashing", , False
End Sub
 
Code:
Private Sub Flash_Cells()

Dim FlashColor As Integer
Dim MakeFlash As Range
Dim x As Integer
Dim TheSpeed
Dim i

'Just a random range of cells. Change it to whatever you want.
Set MakeFlash = Range("A1,C6,F3,H4")

For Each i In MakeFlash

If i.Value > 4 Then

FlashColor = 3 'Set the color to red

'Make the cell range flash fast: 0.10 to slow: 0.99
TheSpeed = 0.2

'Flash 7 times
Do Until x = 100

DoEvents
Start = Timer
Delay = Start + TheSpeed
Do Until Timer > Delay
DoEvents
MakeFlash.Interior.ColorIndex = FlashColor
Loop
Start = Timer
Delay = Start + TheSpeed
Do Until Timer > Delay
DoEvents
MakeFlash.Interior.ColorIndex = xlNone
Loop
x = x + 1
Loop

End If
Next i

End Sub
 
Last edited by a moderator:
Back
Top