flashing cell

Watchdawg

Board Regular
Joined
Jan 21, 2015
Messages
84
My boss has a workbook that I've set up with a quantity in cell U6 and U12. If U12 does NOT match U6, I need the cell to flash until it does match. I need the flashing to not be something that will interfere with re-entering data on the spreadsheet while making corrections, and when it's complete stop the flashing.
I've seen a few things out there that will make the cell flash, but they tend to interrupt the user making corrections.
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
A simple Do-Loop with DoEvents statement could be used :

The following should give you an idea:
In the worksheet module:
VBA Code:
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = [U6].Address Or Target.Address = [U12].Address Then
        Call FlashCell([A1]) '<< change flashing cell as required
    End If
End Sub

Private Sub FlashCell(ByVal Cell As Range)

    Dim t As Single, lInitColor As Long
   
    On Error GoTo Xit
    t = Timer
    With Cell
        lInitColor = .Interior.ColorIndex
        Do While [U6] <> [U12]
            If Int(Timer) Mod 2 Then
                .Interior.Color = vbRed
            Else
                .Interior.Color = vbGreen
            End If
            DoEvents
        Loop
Xit:
        .Interior.ColorIndex = lInitColor
    End With

End Sub

The above assumes the values of cells U6 and U12 are changed by data entry in them not by formulae calculation.
 
Last edited:
Upvote 0
A simple Do-Loop with DoEvents statement could be used :

The following should give you an idea:
In the worksheet module:
VBA Code:
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = [U6].Address Or Target.Address = [U12].Address Then
        Call FlashCell([A1]) '<< change flashing cell as required
    End If
End Sub

Private Sub FlashCell(ByVal Cell As Range)

    Dim t As Single, lInitColor As Long
  
    On Error GoTo Xit
    t = Timer
    With Cell
        lInitColor = .Interior.ColorIndex
        Do While [U6] <> [U12]
            If Int(Timer) Mod 2 Then
                .Interior.Color = vbRed
            Else
                .Interior.Color = vbGreen
            End If
            DoEvents
        Loop
Xit:
        .Interior.ColorIndex = lInitColor
    End With

End Sub

The above assumes the values of cells U6 and U12 are changed by data entry in them not by formulae calculation.
Works like a charm when typing in the quantity, unfortunately both cells are populated by formulas, is there a way to prevent the formulas from interfering with the code?
 
Upvote 0

Forum statistics

Threads
1,214,589
Messages
6,120,416
Members
448,960
Latest member
AKSMITH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top