Blinking Cells

Created by Bill Manville

To create a blinking cell:

If you define a new Style (Format / Style / Flash/ Add ) and apply
that style to the cells you want to flash, paste the following code
into a module sheet and run the procedure Flash from Auto-Open if
desired you will get the text flashing alternately white and red.

Dim NextTime As Date
 
Sub Flash()
  NextTime = Now + TimeValue(“00:00:01”)
  With ActiveWorkbook.Styles(“Flash”).Font
    If .ColorIndex = 2 Then .ColorIndex = 3 Else .ColorIndex = 2
  End With
  Application.OnTime NextTime, “Flash”
End Sub
 
Sub StopIt()
  Application.OnTime NextTime, “Flash”, schedule:=False
  ActiveWorkbook.Styles(“Flash”).Font.ColorIndex = xlAutomatic
End Sub

Editor’s Note: For the love of everything holy, don’t do this.

Posted in Uncategorized

12 thoughts on “Blinking Cells

  1. The traditional way to implement blinking is with code that does the work on a cell by cell basis. Bill’s solution improves on it dramatically by use a style.

    The down side, of course, is that if one wants to change the emphasis method, one must modify VBA code. Another approach that moves the formatting responsibility out of the VBA is at http://www.tmehta.com/tmxl/dbfind_byid.asp?id=14

    One can implement all kinds of neat — including some useful — effects with that technique. Examples include an arrow cycling through some number of cells and a blinking point in a chart!

  2. Hi guys,

    A way to change the method without actually having to modify VBA code would be to set up two more styles. A “Flash_Red” style with red font, and a “Flash_White” style with a white font. The VBA could then be adjusted to:

    Sub Flash()
    NextTime = Now + TimeValue(“00:00:01?)
    With ActiveWorkbook.Styles(“Flash”).Font
    If .ColorIndex = ActiveWorkbook.Styles(“Flash_Red”).Font.ColorIndex Then _
    .ColorIndex = ActiveWorkbook.Styles(“Flash_White”).Font.ColorIndex Else .ColorIndex = _
    ActiveWorkbook.Styles(“Flash_Red”).Font.ColorIndex
    End With
    Application.OnTime NextTime, “Flash”
    End Sub

    Personally, I think I’d opt for John’s method though. :)

  3. I need this function but want it to flash all the time. Everytime someone opens the document that is. I have played with the code but after I save any changes to the document the items I wish to still flash stop. I have to go in to macros and manually start the flash. Where am I messing up? I am new to this stuff in excel.

  4. Guys, I always get an error msg on this one – Application.OnTime NextTime, “Flash”
    – that he cannot find the macro Flash… can you help? Thx

  5. Is there a way to use blinking cells in relation to dates? I have a date field that I would want to blink after three days to show we are coming up on our 3 day deadline.

  6. @Natira: You can’t do anything while this code is running. So every second, you get interrupted for a few milliseconds. You would be killing the user experience to have a blinking cell. It’s the epitome of flash over substance.


Posting code? Use <pre> tags for VBA and <code> tags for inline.

Leave a Reply

Your email address will not be published. Required fields are marked *