VBA – How to blink a cell in Microsoft Excel

This tip may sounds weird, but, who we are to judge other people’s necessities? That has happened some time ago in our forum, where a user asked for a code which is capable to blink a cell in Excel through VBA code. Well, after some coding, here is the result.

Insert this code into your Worksheet code:

Private Sub Worksheet_Calculate()
  If Range("B1").Value > 0 Then
      Blink "A1"
  Else
      Range("A1").Interior.ColorIndex = 0
  End If
End Sub
 
Private Sub Worksheet_Change(ByVal Target As Range)
  Application.Run Me.CodeName & ".Worksheet_Calculate"
End Sub

And this code into a VBA module:

Sub Blink(cell As String)
  If Range(cell).Interior.ColorIndex = 6 Then
      Range(cell).Interior.ColorIndex = 0
  Else
      Range(cell).Interior.ColorIndex = 6
  End If
  Application.OnTime Now + 1 / 86400, "doagain"
End Sub
Sub DoAgain()
  Application.Run Sheets("SuaPlanilha").CodeName & ".Worksheet_Calculate" 'mude aqui no nome da planilha
End Sub

This code blinks the cell A1, if cell B1 is empty.

Reference

http://en.allexperts.com/q/Excel-1059/Excel-blinking-cells.htm

Enjoy!

Comentários

comentários

One thought on “VBA – How to blink a cell in Microsoft Excel”

Comments are closed.