Flashing cells

M

MAX

I need a code to flashing 4 cells in a workbook of 3 sheets.
1. Sheet 1 (Cell A1)
2. Sheet 2 (Cell B1) and
3. Sheet 3 (Cells C1 and C2).
If possible when I open the workbook, I find these 4 cells flashing without
the need of run macro.

Thank you for your help Masters.
 
B

Bernard Liengme

No and if it were possible I would advice against it
Some jurisdictions make flashing cells illegal (trouble for those with
epilepsy)
Think of another way (colour?) to draw attention to the cells
best wishes
 
R

Robert Martim, Excel

Max

You can do as follows.

In ThisWorkbook module, add:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
stopFlashing
End Sub

Private Sub Workbook_Open()
startFlashing
End Sub

In a module, add:

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

Change the code as required for your purpose.
 
M

MAX

I tried it and it didn't work. Why?

Robert Martim said:
Max

You can do as follows.

In ThisWorkbook module, add:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
stopFlashing
End Sub

Private Sub Workbook_Open()
startFlashing
End Sub

In a module, add:

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

Change the code as required for your purpose.

--
Robert
Author of RibbonX: Customizing the Office 2007 Ribbon:
FOR THE LATEST TUTORIALS VISIT:
http://www.msofficegurus.com
 

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

Top