Forum Discussion

knmcbride's avatar
knmcbride
Copper Contributor
Jul 15, 2025

conditional flashing cells

Hello. I would like to make a cell flash if a certain condition is met, ie a value higher than another value. I can find instructions to make a flashing style, but I can't see a way to use this in conditional formatting. Is it possible?

2 Replies

  • Yes, you can make a cell flash only when a condition is met, like when one value exceeds another:

     

    1. Create a Custom Cell Style
    •    Go to the Home tab → Cell Styles → New Cell Style
    •    Name it something like "FlashingText"
    •    Set formatting (e.g. bold red font, colored background)

     

    2. Open the VBA Editor
    •    Press Alt + F11 to open the editor
    •    Insert a new module: Insert → Module

    3. Paste This VBA Code

    Public NextTime As Double
    Public Const FlashRng As String = "Sheet1!A1" ' Change to your target cell
    
    Sub FlashCell()
        If Range(FlashRng).Value > Range("B1").Value Then ' Your condition
            If Range(FlashRng).Style = "FlashingText" Then
                Range(FlashRng).Style = "Normal"
            Else
                Range(FlashRng).Style = "FlashingText"
            End If
            NextTime = Now + TimeSerial(0, 0, 1)
            Application.OnTime NextTime, "FlashCell", , True
        End If
    End Sub
    
    Sub StopFlash()
        On Error Resume Next
        Application.OnTime NextTime, "FlashCell", , False
        Range(FlashRng).Style = "Normal"
    End Sub


    4. Run the Macro
    •    Go to the Developer tab → Macros → Run FlashCell
    •    Or use Workbook_Open to trigger it automatically when the file opens

    • knmcbride's avatar
      knmcbride
      Copper Contributor

      Thank you. I'm sure that would work - but I would have no idea how to modify the code to fit my conditional criteria - in  other words how to fill in the 'your condition' sections. Is there a guide somewhere?

Resources