PDA

View Full Version : Make Cell Blink 3 times



allthingstec
05-04-2018, 03:02 PM
Can someone add to this code so the cell will only blink a set number of times?
Thanks???


Option Explicit

Dim bCellCheck As Boolean
Dim bBlink As Boolean

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim rColumn As Range
Dim sAdress As String

On Error GoTo ErrorHandle

If Not IsEmpty(Range("G4")) Then
Set rColumn = Range("G4")
End If

bCellCheck = False

If Range("I5").Value < (8) Then
bCellCheck = True
If Len(sAdress) > 0 Then
sAdress = sAdress & "," & rColumn.Address
Else
sAdress = sAdress & rColumn.Address
End If
End If

If bCellCheck = True And bBlink = False Then
Set rRange = Range(sAdress)
bBlink = True
StartBlink
ElseIf bCellCheck = True And bBlink = True Then
Set rRange = rColumn
StopBlink
Set rRange = Range(sAdress)
StartBlink
ElseIf bCellCheck = False And bBlink = True Then
Set rRange = rColumn
StopBlink
bBlink = False
End If

Exit Sub
ErrorHandle:
MsgBox Err.Description & " Procedure Worksheet_Change."
Set rRange = Nothing
Set rColumn = Nothing
bCellCheck = False
End Sub

rlv
05-06-2018, 04:01 PM
You did not include the code for StartBlink & StopBlink, but from what I can see by the variables you've used and the structure of your Worksheet_Change code , it looks like your code is based on this example:

http://sitestory.dk/excel_vba/blinking-cells.htm

or something very similar. If so, then the attached mods to StartBlink & StopBlink might be a starting point for what you want to do. The number of blinks is controlled by setting the variable BlinkMax.