ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Flashing cells (https://www.excelbanter.com/excel-worksheet-functions/229071-flashing-cells.html)

Max

Flashing cells
 
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

JBeaucaire[_90_]

Flashing cells
 
Try already published techniques of doing this:

http://www.vbaexpress.com/kb/getarticle.php?kb_id=891

--
"Actually, I *am* a rocket scientist." -- JB

Your feedback is appreciated, click YES if this post helped you.


"MAX" wrote:

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



All times are GMT +1. The time now is 11:45 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com