Flashing cells

M

MAX

I tried the code below for flashing cells, and it didn't work.
Will you please help me.

CODE:
In Workbook

Private Sub Workbook_BeforeClose(Cancel As Boolean)
stopFlashing
End Sub

Private Sub Workbook_Open()
startFlashing
End Sub

In Module

Option Explicit
Dim nextSecond

Sub startFlashing()
flashCell
End Sub

Sub stopFlashing()
On Error Resume Next
Application.OnTime nextSecond, "flashCell", , False
End Sub

Sub flashCell()
nextSecond = Now + TimeValue("00:00:01")
Application.OnTime nextSecond, "flashCell"


If Range("B1").Interior.ColorIndex = 36 Then
Range("B1").Interior.ColorIndex = 41
Range("B1").Value = "Light Blue"
ElseIf Range("B1").Interior.ColorIndex = 41 Then
Range("B1").Interior.ColorIndex = 36
Range("B1").Value = "Light Yellow"
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Code help 6
Cells flashing 2
Adding code 5
Adding code 1
2 codes in one sheet 5
Arrange code 3
Flashing cells 5
Compile error 7

Top