View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
keepITcool keepITcool is offline
external usenet poster
 
Posts: 2,253
Default Combining Modules

could be simpler..

dtFlash must be module level to allow unschedule on close.
nFlash is procedure level, but static so it retains value between runs.

Option Explicit

Dim dtFlash As Date

Sub Flash()
Static nFlash As Integer

With ActiveWorkbook.Styles("Flash")
If .Font.ColorIndex = 3 Then
.Font.ColorIndex = xlColorIndexAutomatic
.Interior.ColorIndex = xlColorIndexNone
Else
.Font.ColorIndex = 3
.Interior.ColorIndex = 19
.Interior.Pattern = xlSolid
End If
End With

'Reschedule or reset
If nFlash 10 Then
nFlash = 0
dtFlash = 0
Else
nFlash = nFlash + 1
dtFlash = Now + TimeValue("00:00:01")
Application.OnTime dtFlash, "Flash"
End If

End Sub

Sub Auto_close()
If dtFlash 0 Then Application.OnTime dtFlash, "Flash", , False
End Sub





--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Bob Phillips wrote :


Sub Flash()
cTimes = cTimes + 1
If cTimes = 10 Then
With ActiveWorkbook.Styles("Flash")
.Font.ColorIndex = xlColorIndexAutomatic
End With
Else
nStart = Now + TimeValue("00:00:01")
With ActiveWorkbook.Styles("Flash")
If .Font.ColorIndex = 3 Then
.Font.ColorIndex = xlColorIndexAutomatic
.Interior.ColorIndex = xlColorIndexNone
Else
.Font.ColorIndex = 3
.Interior.ColorIndex = 19
.Interior.Pattern = xlSolid
End If
End With
Application.OnTime nStart, "Flash"
Application.OnTime nStart, "Flash2"
End If
End Sub