Flashing TextBox

G

grahammal

Dim x As Integer
Dim OrigColor As Integer
Dim NewColor As Integer
Dim CellToFlash As Range
OrigC = ActiveCell.Interior.ColorIndex
NewColor = 16 ' 1st cell color
OrigColor = 2 ' 2nd cell color
Set CellToFlash = Range("L7") ' Cell range to flash
Do Until x = 5 ' Flash 20 times
DoEvents
start = Timer ' Set timer for 1st flash rate
Delay = start + 0.2 ' Set delay for 1st cell color
Do Until Timer > Delay ' Dountil delay is exceeded = start+1
DoEvents
CellToFlash.Interior.ColorIndex = NewColor ' Changes cell color to
1st color
Loop
start = Timer ' Set timer for 2nd flash rate
Delay = start + 0.2 ' Set delay for 2nd cell color
Do Until Timer > Delay
DoEvents
CellToFlash.Interior.ColorIndex = OrigColor ' Changes cell color to
2nd color
Loop
x = x + 1 ' Loop increment
Loop


The above VB makes cell "L7" flash.
How do I modify the above VB to make Label1 on UserForm1 flash instead.
 
T

Tom Ogilvy

Private Sub CommandButton1_Click()
Dim x As Integer
Dim OrigColor As Long
Dim NewColor As Long
Dim CellToFlash As MSForms.Label
OrigC = ActiveCell.Interior.ColorIndex
NewColor = RGB(255, 0, 0) ' 1st cell color
OrigColor = Me.Label1.BackColor
Set CellToFlash = Me.Label1 ' Cell range to flash
Do Until x = 5 ' Flash 20 times
DoEvents
Start = Timer ' Set timer for 1st flash rate
Delay = Start + 0.2 ' Set delay for 1st cell color
Do Until Timer > Delay ' Dountil delay is exceeded = start+1
DoEvents
CellToFlash.BackColor = NewColor ' Changes cell color to
Loop
Start = Timer ' Set timer for 2nd flash rate
Delay = Start + 0.2 ' Set delay for 2nd cell color
Do Until Timer > Delay
DoEvents
CellToFlash.BackColor = OrigColor ' Changes cell color to
Loop
x = x + 1 ' Loop increment
Loop

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Flashing UserForm Label 1
Flashing cells 0
Help with VBA 3
Macro help 0
OLE Object on Sheet updates Value in Code but not its Display 3
VBA for Dependents shortcut menu 0
Creative graphics 2
to many e-mails 2

Top