Thread: Code help
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 390
Default Code help

I want cell B1 Flashing in all 3 sheets with blue and yellow.

"FSt1" wrote:

hi
what is it doing/not doing?????

i suspect that you haven't defined nextsecond properly.

Regards
FSt1

"MAX" wrote:

Will you please tell me what I have wrong with this 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
Sheet1.Range("B1").Interior.ColorIndex = 41
Sheet1.Range("B1").Value = "Light Blue"

Sheet2.Range("B1").Interior.ColorIndex = 41
Sheet2.Range("B1").Value = "Light Blue"

Sheet3.Range("B1").Interior.ColorIndex = 41
Sheet3.Range("B1").Value = "Light Blue"

ElseIf Range("B1").Interior.ColorIndex = 41 Then
Sheet1.Range("B1").Interior.ColorIndex = 36
Sheet1.Range("B1").Value = "Light Yellow"

Sheet2.Range("B1").Interior.ColorIndex = 36
Sheet2.Range("B1").Value = "Light Yellow"

Sheet3.Range("B1").Interior.ColorIndex = 36
Sheet3.Range("B1").Value = "Light Yellow"
End If
End Sub