Flashing Text

It is very easy to create cells that flash using a bit of VBA code.
The first step is to create a new style called "Flash". Select (Format > Styles) and type "Flash" and press Add.
This is the style you apply to any cells that you want to flash.
Lets assume you want to the cells to flash constantly while the workbook is open.
We need to add the following 2 lines of code to the events "Workbook_Open" and "Workbook_BeforeClose".
This code needs to be put in the ThisWorkbook code module.

Private Sub Workbook_Open() 
   Call StartFlashing
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
   Call StopFlashing
End Sub

Create a new code module and add the following three subroutines.


Flash Text Subroutine

The FlashText subroutine just changes the properties of the Flash style every second to create a flashing effect.

Public Sub StartFlashing() 
   Application.OnTime EarliestTime:=Now() + TimeSerial(0, 0, 1), _
                      Procedure:="FlashText", _
                      Schedule:=True
End Sub
Public Sub StopFlashing()
   On Error Resume Next
   Application.OnTime EarliestTime:=Now() + TimeSerial(0, 0, 1), _
                      Procedure:="FlashText", _
                      Schedule:=False
End Sub
Public Sub FlashText()
   Static bBoolean As Boolean
   With ActiveWorkbook.Styles("Flash")
      If bBoolean = True Then
         .Font.Color = RGB(255, 255, 255)
         .Interior.Color = RGB(10, 10, 255)
      Else
         .Font.Color = RGB(0, 0, 0)
         .Interior.ColorIndex = xlNone
      End If
   End With
      
   bBoolean = Not bBoolean
   Application.OnTime EarliestTime:=Now() + TimeSerial(0, 0, 1), _
                      Procedure:="FlashText", _
                      Schedule:=True
End Sub

© 2019 Better Solutions Limited. All Rights Reserved. © 2019 Better Solutions Limited TopPrevNext